:root {
  color-scheme: light;
  --bg: #f3f5ff;
  --bg-deep: #e8ebff;
  --panel: #ffffff;
  --panel-soft: #f8f9ff;
  --ink: #202653;
  --muted: #68719a;
  --line: #dfe3f5;
  --purple: #5b4ae8;
  --purple-deep: #3f319f;
  --purple-soft: #eeeaff;
  --sky: #23b9df;
  --sky-soft: #e4f9ff;
  --yellow: #ffd45c;
  --yellow-soft: #fff6cf;
  --coral: #ff7168;
  --coral-soft: #fff0ed;
  --green: #36b77a;
  --green-soft: #e9f9f1;
  /* ConVoice layout rhythm, adapted to large child-friendly controls. */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-full: 999px;
  --shadow-1: 0 1px 3px rgba(48, 48, 110, 0.08);
  --shadow-2: 0 8px 24px rgba(48, 48, 110, 0.12);
  --shadow: 0 12px 32px rgba(48, 48, 110, 0.12);
  --shadow-soft: var(--shadow-1);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 0;
  min-height: 100svh;
  color: var(--ink);
  background:
    radial-gradient(circle at 5% 0%, rgba(91, 74, 232, 0.13), transparent 28rem),
    radial-gradient(circle at 95% 20%, rgba(35, 185, 223, 0.12), transparent 24rem),
    linear-gradient(180deg, var(--bg), var(--bg-deep));
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
summary:focus-visible,
label:focus-within {
  outline: 3px solid rgba(35, 185, 223, 0.45);
  outline-offset: 3px;
}

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

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(100%, 860px);
  min-height: 100svh;
  margin: 0 auto;
  padding: 0 18px calc(96px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 0 10px;
  background: linear-gradient(180deg, rgba(243, 245, 255, 0.98) 65%, rgba(243, 245, 255, 0));
  backdrop-filter: blur(14px);
}

.brand-button,
.icon-button,
.back-button,
.text-button,
.danger-link {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.brand-button {
  display: flex;
  align-items: center;
  max-width: calc(100% - 142px);
  padding: 4px 0;
  text-align: left;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  margin-right: 10px;
  place-items: center;
  border-radius: 14px;
  background: var(--purple);
  box-shadow: 0 7px 18px rgba(91, 74, 232, 0.25);
  font-size: 22px;
}

.brand-button strong,
.brand-button small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-button strong {
  font-size: 15px;
  font-weight: 700;
}

.brand-button small {
  color: var(--muted);
  font-size: 12px;
}

.icon-button {
  display: grid;
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-soft);
  font-size: 18px;
}

.header-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.preview-mode-toggle {
  display: grid;
  min-width: 66px;
  min-height: 52px;
  padding: 5px 8px;
  place-items: center;
  border: 1px solid rgba(91, 74, 232, 0.2);
  border-radius: 18px;
  color: var(--purple-deep);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  font: inherit;
}

.preview-mode-toggle > span { font-size: 22px; line-height: 1; }
.preview-mode-toggle small { font-size: 10px; font-weight: 900; }

.preview-mode-toggle.is-active {
  border-color: rgba(255, 196, 45, 0.82);
  color: #694c00;
  background: linear-gradient(145deg, #fff7c9, #ffd45c);
  box-shadow: 0 5px 15px rgba(186, 137, 14, 0.24);
}

.main-content {
  min-height: 540px;
}

.screen {
  padding: 12px 0 28px;
  animation: screen-in 260ms ease-out both;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

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

h1 {
  margin-bottom: 10px;
  font-size: clamp(28px, 6vw, 44px);
  line-height: 1.13;
  letter-spacing: -0.04em;
}

h2 {
  margin-bottom: 6px;
  font-size: clamp(20px, 4vw, 27px);
  line-height: 1.25;
  letter-spacing: -0.025em;
}

.lead {
  max-width: 600px;
  color: var(--muted);
  font-size: clamp(16px, 3.5vw, 19px);
}

.eyebrow,
.section-kicker {
  display: block;
  margin-bottom: 7px;
  color: var(--purple);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero-card {
  position: relative;
  overflow: hidden;
  padding: clamp(24px, 6vw, 42px);
  border-radius: 32px;
  color: #fff;
  background:
    radial-gradient(circle at 85% 15%, rgba(255, 212, 92, 0.22), transparent 12rem),
    radial-gradient(circle at 72% 65%, rgba(35, 185, 223, 0.25), transparent 15rem),
    linear-gradient(145deg, #5b4ae8, #3d3099 70%);
  box-shadow: 0 12px 32px rgba(63, 49, 159, 0.18);
}

.hero-card::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, 0.45) 1px, transparent 1px);
  background-size: 22px 22px;
  content: "";
  mask-image: linear-gradient(90deg, transparent 18%, #000 100%);
}

.hero-copy {
  position: relative;
  z-index: 2;
  max-width: 470px;
}

.hero-copy .eyebrow {
  color: #d7d1ff;
}

.hero-copy h1 {
  margin-bottom: 12px;
}

.hero-copy p {
  max-width: 440px;
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.82);
}

.train-scene {
  position: relative;
  z-index: 1;
  height: 180px;
  margin: 10px 0 0;
}

.train {
  position: absolute;
  right: 8%;
  bottom: 25px;
  width: 210px;
  height: 88px;
  animation: train-bob 2.4s ease-in-out infinite;
}

.train-cab {
  position: absolute;
  right: 44px;
  bottom: 17px;
  display: grid;
  width: 102px;
  height: 68px;
  place-items: center;
  border: 6px solid #27225f;
  border-radius: 20px 22px 10px 10px;
  background: var(--coral);
}

.train-cab::before {
  position: absolute;
  top: -26px;
  left: 12px;
  width: 70px;
  height: 24px;
  border-radius: 12px 12px 4px 4px;
  background: var(--yellow);
  content: "";
}

.train-cab span {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  color: var(--purple-deep);
  background: #dff9ff;
  font-size: 20px;
}

.train-nose {
  position: absolute;
  right: 0;
  bottom: 17px;
  width: 62px;
  height: 47px;
  border: 6px solid #27225f;
  border-left: 0;
  border-radius: 0 28px 12px 0;
  background: var(--sky);
}

.train-nose::after {
  position: absolute;
  right: -10px;
  bottom: -6px;
  width: 27px;
  height: 15px;
  border-radius: 6px;
  background: var(--yellow);
  content: "";
}

.train-wheel {
  position: absolute;
  bottom: 0;
  width: 39px;
  height: 39px;
  border: 7px solid #24204f;
  border-radius: 50%;
  background: var(--yellow);
}

.wheel-a { right: 115px; }
.wheel-b { right: 20px; }

.train-smoke {
  position: absolute;
  right: 12px;
  top: -16px;
  font-size: 35px;
  animation: smoke-float 2.1s ease-out infinite;
}

.track-line,
.moving-track {
  position: absolute;
  right: 2%;
  bottom: 17px;
  width: 72%;
  height: 7px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.45);
  box-shadow: 0 14px 0 rgba(255, 255, 255, 0.18);
}

.star,
.monster {
  position: absolute;
}

.star { color: var(--yellow); font-size: 24px; }
.star-one { top: 24px; left: 50%; }
.star-two { top: 58px; right: 4%; font-size: 14px; }

.monster {
  display: grid;
  width: 62px;
  height: 58px;
  place-items: center;
  border: 4px solid rgba(255, 255, 255, 0.35);
  border-radius: 48% 52% 42% 58%;
  color: var(--purple-deep);
  background: var(--yellow);
  font-size: 13px;
  font-weight: 900;
}

.monster-one { bottom: 28px; left: 8%; transform: rotate(-7deg); }
.monster-two { right: 34%; bottom: 54px; width: 51px; height: 47px; background: #91f0d0; transform: rotate(8deg); }

@keyframes train-bob {
  0%, 100% { transform: translateY(0) rotate(-0.5deg); }
  50% { transform: translateY(-5px) rotate(0.5deg); }
}

@keyframes smoke-float {
  0% { opacity: 0; transform: translate(0, 8px) scale(0.7); }
  45% { opacity: 1; }
  100% { opacity: 0; transform: translate(-25px, -28px) scale(1.2); }
}

.journey-status {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding: 16px 18px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  background: rgba(20, 16, 74, 0.28);
  backdrop-filter: blur(8px);
}

.journey-status > div:not(.status-divider) {
  min-width: 0;
}

.status-label {
  display: block;
  margin-bottom: 3px;
  color: inherit;
  opacity: 0.7;
  font-size: 12px;
  font-weight: 700;
}

.status-divider {
  width: 1px;
  height: 32px;
  background: currentColor;
  opacity: 0.18;
}

.energy-pips {
  display: flex;
  gap: 6px;
}

.energy-pip {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 5px 10px 5px 10px;
  opacity: 0.34;
  transform: rotate(45deg) scale(0.72);
}

.energy-pip.is-filled {
  border-color: var(--yellow);
  background: var(--yellow);
  box-shadow: 0 0 14px rgba(255, 212, 92, 0.75);
  opacity: 1;
}

.energy-pips.large {
  margin: 9px 0;
  color: var(--purple);
}

.energy-pips.large .energy-pip {
  width: 24px;
  height: 24px;
}

.panel {
  margin-top: var(--sp-6);
  padding: clamp(20px, 5vw, 30px);
  border: 0;
  border-radius: var(--r-xl);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-1);
}

.section-heading,
.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.section-heading {
  margin-bottom: var(--sp-4);
}

.section-heading.compact {
  align-items: center;
  margin-bottom: var(--sp-3);
}

.section-heading h2,
.page-heading h1 {
  margin-bottom: 0;
}

.page-heading {
  align-items: center;
  margin: 8px 2px 22px;
}

.parent-badge,
.station-pill,
.meta-chip,
.tool-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.parent-badge {
  flex: 0 0 auto;
  color: var(--green);
  background: var(--green-soft);
}

.choice-group {
  margin: 0 0 24px;
  padding: 0;
  border: 0;
}

.choice-group legend,
.field-label {
  display: block;
  margin-bottom: var(--sp-2);
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-2);
  padding: var(--sp-1);
  border-radius: var(--r-lg);
  background: var(--panel-soft);
}

.segmented button,
.mode-option {
  min-height: 48px;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  cursor: pointer;
  font-weight: 800;
}

.segmented button.is-selected,
.mode-option.is-selected {
  color: var(--purple-deep);
  background: #fff;
  box-shadow: var(--shadow-1);
  outline: 2px solid rgba(91, 74, 232, 0.24);
  outline-offset: -2px;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-2);
}

.mode-option {
  display: grid;
  grid-template-columns: 38px 1fr;
  grid-template-rows: auto auto;
  min-height: 78px;
  padding: 13px;
  border: 1px solid transparent;
  text-align: left;
  background: var(--panel-soft);
}

.mode-option > span {
  grid-row: 1 / 3;
  align-self: center;
  font-size: 27px;
}

.mode-option strong,
.mode-option small {
  display: block;
}

.mode-option small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.mode-option.is-selected small {
  color: var(--muted);
}

.mode-option.is-selected {
  color: var(--ink);
  border-color: rgba(91, 74, 232, 0.38);
  background: var(--purple-soft);
  box-shadow: none;
}

.timer-mode-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.timer-mode-option {
  display: grid;
  grid-template-columns: 44px 1fr;
  grid-template-rows: auto auto;
  min-height: 78px;
  padding: 12px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--r-lg);
  text-align: left;
  background: var(--panel-soft);
  cursor: pointer;
}

.timer-mode-option > span {
  grid-row: 1 / 3;
  font-size: 29px;
}

.timer-mode-option strong,
.timer-mode-option small {
  display: block;
}

.timer-mode-option small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.timer-mode-option.is-selected {
  border-color: rgba(91, 74, 232, 0.38);
  color: var(--ink);
  background: var(--purple-soft);
  box-shadow: none;
}

.timer-mode-option.is-selected small {
  color: var(--muted);
}

.countdown-setting {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 13px;
  border-radius: 17px;
  background: var(--yellow-soft);
}

.countdown-setting > span {
  font-size: 13px;
  font-weight: 800;
}

.countdown-setting > small {
  color: #725a0a;
  font-size: 11px;
  font-weight: 700;
}

.countdown-options {
  grid-template-columns: repeat(4, 1fr);
  background: rgba(255, 255, 255, 0.7);
}

.switch-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}

.switch-control {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: var(--sp-2);
  align-items: center;
  padding: 13px;
  border: 1px solid transparent;
  border-radius: var(--r-lg);
  background: var(--panel-soft);
  cursor: pointer;
}

.switch-control input {
  position: absolute;
  opacity: 0;
}

.switch-track {
  position: relative;
  width: 42px;
  height: 25px;
  border-radius: 99px;
  background: #c9cede;
  transition: background 180ms ease;
}

.switch-track::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 7px rgba(32, 38, 83, 0.24);
  content: "";
  transition: transform 180ms ease;
}

.switch-control input:checked + .switch-track {
  background: var(--purple);
}

.switch-control input:checked + .switch-track::after {
  transform: translateX(17px);
}

.switch-control strong,
.switch-control small {
  display: block;
}

.switch-control strong { font-size: 14px; }
.switch-control small { color: var(--muted); font-size: 11px; }

.pool-summary {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 48px;
  margin-bottom: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  color: var(--purple-deep);
  background: var(--purple-soft);
}

.pool-summary > span:first-child { font-size: 22px; }

.setup-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(190px, 1fr);
  gap: var(--sp-4);
  align-items: stretch;
}

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

.setup-controls .choice-group:last-of-type {
  margin-bottom: var(--sp-4);
}

.setup-controls .switch-row {
  margin-bottom: 0;
}

.game-category-options { display: flex; flex-wrap: wrap; gap: 8px; }
.game-category-options label { position: relative; cursor: pointer; }
.game-category-options input { position: absolute; opacity: 0; pointer-events: none; }
.game-category-options span { display: block; padding: 9px 11px; border: 1px solid var(--line); border-radius: 16px; color: var(--muted); background: var(--panel-soft); font-size: 13px; font-weight: 800; }
.game-category-options input:checked + span { border-color: var(--purple); color: var(--purple-deep); background: var(--purple-soft); box-shadow: 0 3px 9px rgba(91,74,232,.12); }

.setup-draw-panel {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: var(--sp-3);
  border: 1px solid rgba(91, 74, 232, 0.16);
  border-radius: var(--r-xl);
  background: linear-gradient(150deg, rgba(235, 233, 255, 0.92), rgba(246, 248, 255, 0.9));
}

.setup-draw-panel .pool-summary {
  min-height: 0;
  margin-bottom: var(--sp-3);
  padding: 10px 11px;
  font-size: 12px;
}

.setup-draw-panel .fine-print {
  margin: var(--sp-2) 3px 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  text-align: center;
}

.primary-button,
.secondary-button,
.rescue-button,
.danger-button {
  min-height: 48px;
  padding: 12px 18px;
  border-radius: var(--r-md);
  cursor: pointer;
  font-weight: 800;
}

.primary-button {
  border: 0;
  color: #fff;
  background: var(--purple);
  box-shadow: var(--shadow-1);
}

.primary-button:active,
.secondary-button:active,
.rescue-button:active {
  transform: translateY(1px);
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--panel-soft);
}

.rescue-button {
  border: 1px solid #bfeafa;
  color: #127d9a;
  background: var(--sky-soft);
}

.danger-button {
  border: 0;
  color: #fff;
  background: #c43f49;
}

.big-button {
  width: 100%;
  min-height: 58px;
  font-size: 17px;
}

.kid-action {
  display: grid;
  width: min(100%, 260px);
  min-height: 148px;
  margin-inline: auto;
  padding: 16px 12px;
  place-items: center;
  gap: 8px;
  border-radius: 28px;
  text-align: center;
}

.kid-action-icon {
  display: grid;
  width: 78px;
  height: 78px;
  place-items: center;
  border-radius: 26px;
  background: var(--panel-soft);
  box-shadow: 0 6px 14px rgba(70, 53, 159, .14);
  font-size: 43px;
  line-height: 1;
}

.primary-button.kid-action .kid-action-icon {
  background: rgba(255, 255, 255, 0.2);
}

.rescue-button.kid-action .kid-action-icon {
  background: rgba(255, 255, 255, 0.72);
}

.kid-action-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
  justify-items: center;
}

.kid-action-copy strong,
.kid-action-copy small {
  display: block;
}

.kid-action-copy strong {
  font-size: 20px;
  line-height: 1.2;
}

.kid-action-copy small {
  display: none;
}

.kid-icon-button {
  width: 58px;
  height: 58px;
  border-radius: 20px;
  font-size: 27px;
}

.fine-print,
.ticket-status {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.center-stage {
  width: min(100%, 650px);
  margin: 30px auto 0;
  text-align: center;
}

.back-button {
  min-height: 48px;
  padding: 5px 3px;
  color: var(--muted);
  font-weight: 700;
}

.palm-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(12px, 4vw, 24px);
  margin: 34px 0 10px;
}

.palm-button {
  min-height: 230px;
  padding: 22px 12px;
  border: 2px solid var(--line);
  border-radius: 30px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

.palm-button:not(:disabled):active {
  transform: scale(0.97);
}

.palm-button.is-lit {
  border-color: var(--yellow);
  color: var(--purple-deep);
  background: var(--yellow-soft);
  box-shadow: 0 0 0 8px rgba(255, 212, 92, 0.2), var(--shadow);
}

.palm-icon {
  display: block;
  margin-bottom: 12px;
  font-size: clamp(70px, 16vw, 110px);
  filter: grayscale(0.25);
}

.palm-button strong,
.palm-button small {
  display: block;
}

.palm-button strong { font-size: 18px; }
.palm-button small { color: var(--muted); font-size: 12px; }

.power-connector {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--yellow);
}

.power-connector span {
  flex: 1;
  height: 4px;
  border-radius: 99px;
  background: currentColor;
  opacity: 0.4;
}

.power-connector i {
  font-style: normal;
  font-size: 25px;
}

.draw-window {
  position: relative;
  overflow: hidden;
  min-height: 310px;
  margin: 32px 0 20px;
  border-radius: 32px;
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 255, 255, 0.52), transparent 11rem),
    linear-gradient(180deg, #dff8ff 0 61%, #b8e98a 61% 100%);
  box-shadow: var(--shadow);
}

.station-clouds {
  position: absolute;
  top: 24px;
  left: 0;
  width: 100%;
  color: #fff;
  font-size: 40px;
  animation: clouds 4s linear infinite;
}

.station-reel {
  position: absolute;
  top: 80px;
  left: 0;
  display: flex;
  align-items: center;
  gap: 38px;
  width: max-content;
  animation: reel-move 900ms linear infinite;
}

.reel-station {
  display: grid;
  width: 108px;
  height: 105px;
  place-items: center;
  border: 5px solid #fff;
  border-radius: 28px 28px 8px 8px;
  background: var(--purple-soft);
  box-shadow: 0 8px 20px rgba(32, 38, 83, 0.14);
  font-size: 46px;
}

.moving-train {
  position: absolute;
  z-index: 2;
  bottom: 39px;
  left: 50%;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  font-size: 70px;
  transform: translateX(-50%);
  animation: fast-bob 360ms ease-in-out infinite alternate;
}

.moving-train span {
  padding-bottom: 11px;
  color: var(--coral);
  font-size: 43px;
}

.moving-track {
  right: 0;
  bottom: 37px;
  width: 100%;
  height: 9px;
  background: #6d6576;
  box-shadow: 0 17px 0 #8e8397;
}

@keyframes clouds {
  from { transform: translateX(-20%); }
  to { transform: translateX(20%); }
}

@keyframes reel-move {
  from { transform: translateX(-146px); }
  to { transform: translateX(0); }
}

@keyframes fast-bob {
  from { transform: translate(-50%, 0) rotate(-1deg); }
  to { transform: translate(-50%, -6px) rotate(1deg); }
}

.draw-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.draw-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--purple);
  animation: dot-pulse 900ms ease-in-out infinite alternate;
}

.draw-dots span:nth-child(2) { animation-delay: 150ms; }
.draw-dots span:nth-child(3) { animation-delay: 300ms; }

@keyframes dot-pulse {
  from { opacity: 0.25; transform: translateY(0); }
  to { opacity: 1; transform: translateY(-6px); }
}

.reveal-stage {
  padding: clamp(25px, 6vw, 40px);
  border-radius: 32px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.reveal-stage .game-hero-icon {
  width: 176px;
  height: 176px;
  margin-bottom: 12px;
  font-size: 92px;
}

.reveal-stage h1 { margin: 4px 0 6px; font-size: clamp(36px, 9vw, 52px); }
.reveal-simple-goal { margin: 0 0 18px; color: var(--purple); font-size: clamp(20px, 5vw, 27px); font-weight: 900; }
.reveal-picture-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 12px;
}
#revealScreen .reveal-picture-actions { display: grid !important; }
#revealScreen .reveal-picture-button { display: grid !important; }
.reveal-picture-button {
  display: grid;
  min-height: 182px;
  padding: 16px 8px;
  place-items: center;
  border-radius: 30px;
  text-align: center;
  cursor: pointer;
}
.reveal-picture-button .kid-action-icon {
  width: 92px;
  height: 92px;
  border-radius: 28px;
  font-size: 54px;
}
.reveal-picture-button .kid-action-copy { display: block; margin-top: 9px; }
.reveal-picture-button .kid-action-copy strong { font-size: 22px; }
.reveal-picture-button .kid-action-copy small { display: none; }
.reveal-picture-button:disabled { opacity: .4; filter: grayscale(.45); }
.reveal-stage .ticket-status { display: none; }

.game-actions .kid-action.is-crystal-picture {
  display: grid !important;
  min-height: 174px;
  padding: 16px;
  place-items: center;
  border-radius: 30px;
  text-align: center;
}
.game-actions .is-crystal-picture .kid-action-icon { width: 92px; height: 92px; border-radius: 28px; font-size: 56px; }
.game-actions .is-crystal-picture .kid-action-copy { margin-top: 7px; }
.game-actions .is-crystal-picture .kid-action-copy strong { font-size: 23px; }
.game-actions .is-crystal-picture .kid-action-copy small { display: none; }

.station-pill {
  margin-bottom: 18px;
  color: var(--purple-deep);
  background: var(--purple-soft);
}

.game-hero-icon,
.guide-visual {
  display: grid;
  width: 142px;
  height: 142px;
  margin: 0 auto 24px;
  place-items: center;
  border-radius: 48% 52% 46% 54%;
  background: linear-gradient(145deg, var(--yellow-soft), #fff);
  box-shadow: 0 15px 36px rgba(83, 72, 150, 0.17);
  font-size: 72px;
  animation: icon-float 2.5s ease-in-out infinite;
}

@keyframes icon-float {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-7px) rotate(2deg); }
}

.meta-row,
.tool-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 18px 0;
}

.meta-chip {
  color: var(--purple-deep);
  background: var(--panel-soft);
}

.tool-chip {
  color: #126f8a;
  background: var(--sky-soft);
}

.reveal-stage .secondary-button {
  width: 100%;
  margin-top: 10px;
}

.game-topline {
  display: grid;
  grid-template-columns: 58px 1fr 58px;
  gap: 10px;
  align-items: center;
  margin: 5px 0 24px;
}

.game-timer-panel {
  width: min(100%, 430px);
  margin: -12px auto 14px;
  padding: 6px;
  border: 1px solid #d7d2ff;
  border-radius: 20px;
  color: var(--purple-deep);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-soft);
}

.timer-switch-pill { display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px; padding: 3px; border-radius: 999px; background: #f1effc; }
.timer-switch-pill.is-setting { grid-template-columns: minmax(0, .8fr) minmax(0, .8fr) minmax(78px, .7fr) 43px; border-radius: 20px; }
.timer-line-option {
  display: grid;
  min-height: 50px;
  grid-template-columns: 25px auto 1fr;
  column-gap: 3px;
  align-items: center;
  padding: 7px 11px;
  border: 0;
  border-radius: 999px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}
.timer-line-option > span { font-size: 21px; }
.timer-line-option strong { font-size: 15px; white-space: nowrap; }
.timer-line-option b { display: none; justify-self: end; font-size: 16px; font-variant-numeric: tabular-nums; }
.timer-line-option.is-selected { color: #fff; background: var(--purple); box-shadow: 0 4px 10px rgba(91, 74, 232, .24); }
.timer-line-option.is-selected b { display: block; }
.timer-switch-pill.is-setting .timer-line-option { min-height: 50px; padding: 6px; grid-template-columns: 1fr; justify-items: center; }
.timer-switch-pill.is-setting .timer-line-option > span { display: none; }
.timer-switch-pill.is-setting .timer-line-option strong { font-size: 13px; }
.timer-switch-pill.is-setting .timer-line-option.is-selected b { font-size: 13px; }

.game-countdown-setting {
  display: contents;
}
.game-countdown-setting select { min-width: 0; min-height: 46px; padding: 0 4px; border: 0; border-radius: 999px; color: var(--ink); background: #fff4c7; font: inherit; font-size: 14px; font-weight: 800; text-align: center; }
.game-countdown-setting button { border: 0; border-radius: 50%; color: #fff; background: var(--purple); font: inherit; font-size: 21px; font-weight: 900; cursor: pointer; }

.game-timer-panel.is-urgent {
  border-color: #ffb55c;
  color: #8c3e00;
  background: #fff1df;
  animation: timer-urgent 700ms ease-in-out infinite alternate;
}

.game-timer-panel.is-arrived {
  border-color: var(--green);
  color: #226a52;
  background: var(--green-soft);
}

@keyframes timer-urgent {
  to { transform: scale(1.025); box-shadow: 0 0 0 6px rgba(255, 181, 92, 0.13); }
}

.step-navigator {
  display: grid;
  min-width: 0;
  grid-template-columns: 32px minmax(70px, 1fr) 32px;
  gap: 4px;
  align-items: center;
}

.step-navigator-center {
  display: grid;
  min-width: 0;
  gap: 5px;
  justify-items: center;
}

.step-navigator-center small {
  overflow: hidden;
  max-width: 100%;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.step-arrow {
  display: grid;
  width: 32px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--purple-deep);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
}

.step-progress {
  display: flex;
  justify-content: center;
  gap: 7px;
}

.step-dot {
  width: 11px;
  height: 11px;
  border-radius: 99px;
  background: var(--line);
  transition: width 180ms ease, background 180ms ease;
}

.step-dot.is-current {
  width: 36px;
  background: var(--purple);
}

.step-dot.is-done {
  background: var(--green);
}

.game-guide {
  width: min(100%, 650px);
  margin: 0 auto;
  padding: clamp(24px, 7vw, 42px);
  border-radius: 32px;
  text-align: center;
  touch-action: pan-y;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.game-guide.is-swipe-left {
  animation: guide-swipe-left 220ms ease-out;
}

.game-guide.is-swipe-right {
  animation: guide-swipe-right 220ms ease-out;
}

@keyframes guide-swipe-left {
  0% { transform: translateX(0); }
  45% { transform: translateX(-16px); }
  100% { transform: translateX(0); }
}

@keyframes guide-swipe-right {
  0% { transform: translateX(0); }
  45% { transform: translateX(16px); }
  100% { transform: translateX(0); }
}

.guide-visual {
  width: 125px;
  height: 125px;
  font-size: 62px;
}

.guide-visual.is-sequence {
  display: flex;
  width: min(100%, 390px);
  height: 148px;
  padding: 16px 10px 12px;
  justify-content: center;
  gap: clamp(4px, 2vw, 12px);
  border-radius: 30px;
  font-size: inherit;
  animation: none;
}

.guide-step {
  position: relative;
  display: grid;
  flex: 0 1 78px;
  width: clamp(58px, 18vw, 78px);
  height: 116px;
  padding: 5px 3px 7px;
  align-content: center;
  place-items: center;
  border: 3px solid transparent;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 7px 16px rgba(83, 72, 150, 0.1);
  opacity: 0.48;
  transition: transform 180ms ease, opacity 180ms ease, border-color 180ms ease;
}

.guide-emoji { font-size: clamp(28px, 7vw, 40px); line-height: 1; }
.guide-step b {
  display: -webkit-box;
  overflow: hidden;
  margin-top: 5px;
  color: var(--ink);
  font-size: 10px;
  line-height: 1.22;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.guide-step small {
  position: absolute;
  top: -9px;
  left: -7px;
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--purple);
  font-size: 13px;
  font-weight: 800;
}

.guide-step.is-current {
  border-color: var(--purple);
  opacity: 1;
  transform: scale(1.06);
}

.guide-step.is-done {
  opacity: 0.78;
}

.guide-step.is-done small {
  background: var(--green);
}

.guide-arrow {
  flex: 0 0 auto;
  color: var(--purple);
  font-size: clamp(18px, 5vw, 28px);
  font-weight: 900;
  opacity: 0.5;
}

.instruction {
  max-width: 520px;
  min-height: 72px;
  margin: 18px auto;
  color: var(--ink);
  font-size: clamp(20px, 4.8vw, 28px);
  font-weight: 800;
  line-height: 1.4;
}

.voice-fallback {
  margin: -8px auto 14px;
  padding: 9px 12px;
  border-radius: 14px;
  color: #6e5500;
  background: var(--yellow-soft);
  font-size: 13px;
  font-weight: 700;
}

.large-tools {
  min-height: 36px;
}

.game-demo {
  max-width: 520px;
  margin: 12px auto 0;
  padding: 13px;
  border: 1px solid rgba(91, 74, 232, .18);
  border-radius: 20px;
  background: linear-gradient(135deg, #f4f1ff, #ecfbff);
}
.game-demo p { margin: 0 0 10px; color: var(--ink); font-size: 14px; font-weight: 800; }
.sound-command-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sound-command {
  min-height: 100px;
  padding: 8px 4px;
  border: 2px solid #d9d2fb;
  border-radius: 16px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
}
.sound-command:active { transform: scale(.96); background: var(--yellow-soft); }
.sound-command span, .sound-command strong, .sound-command small { display: block; }
.sound-command span { font-size: 28px; }
.sound-command strong { margin-top: 2px; font-size: 14px; }
.sound-command small { margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 700; }
.demo-tip { display: block; margin-top: 9px; color: var(--purple-deep); font-size: 12px; font-weight: 800; }
.action-sequence { display: flex; align-items: center; justify-content: center; gap: 5px; }
.action-sequence span { display: grid; min-width: 62px; padding: 5px 3px; place-items: center; border-radius: 13px; background: #fff; }
.action-sequence i { font-size: 27px; font-style: normal; }
.action-sequence b { font-size: 10px; line-height: 1.2; }
.action-sequence em { color: var(--purple); font-size: 18px; font-style: normal; font-weight: 900; }
.demo-replay { width: 100%; min-height: 42px; margin-top: 10px; border: 0; border-radius: 13px; color: #fff; background: var(--purple); font: inherit; font-size: 13px; font-weight: 800; cursor: pointer; }

.helper-note {
  margin: 16px 0;
  padding: 14px;
  border-radius: 15px;
  color: #6e5500;
  background: var(--yellow-soft);
  font-weight: 700;
}

.game-actions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.previous-step-button {
  border-color: #d7d2ff;
  color: var(--purple-deep);
  background: var(--purple-soft);
}

.completion-stage {
  position: relative;
  width: min(100%, 840px);
  min-height: 660px;
  padding: 20px 0 0;
}

.crystal-track-board {
  position: relative;
  overflow: visible;
  width: min(100%, 820px);
  aspect-ratio: 600 / 640;
  margin: 24px auto 14px;
  border: 0;
  border-radius: 0;
  touch-action: none;
  background: transparent;
  box-shadow: none;
}

.letter-route-card {
  position: absolute;
  z-index: 4;
  top: 20px;
  left: 20px;
  display: grid;
  width: 152px;
  min-height: 130px;
  padding: 12px;
  place-items: center;
  border: 2px solid rgba(91, 74, 232, 0.16);
  border-radius: 26px;
  color: var(--purple-deep);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 12px 28px rgba(62, 48, 152, 0.13);
  backdrop-filter: blur(8px);
}

.letter-route-card span,
.letter-route-card small { font-weight: 800; }
.letter-route-card strong { font-size: 50px; line-height: .85; }
.letter-route-card small { font-size: 11px; line-height: 1.3; }

.crystal-track-board.is-word-track .letter-route-card {
  top: 14px;
  left: 50%;
  width: 250px;
  min-height: 112px;
  padding: 9px 16px;
  transform: translateX(-50%);
}

.crystal-track-board.is-word-track .letter-route-card strong {
  font-size: 36px;
  letter-spacing: .08em;
}

.crystal-track-board.is-word-track .letter-route-card small {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.word-meaning-icon {
  display: inline-grid;
  width: 48px;
  height: 48px;
  place-items: center;
  font-size: 40px;
  line-height: 1;
  filter: drop-shadow(0 4px 5px rgba(62, 48, 152, 0.14));
}

.word-meaning-label {
  font-size: 14px;
  line-height: 1;
}

.core-zone {
  position: absolute;
  z-index: 4;
  top: 12%;
  left: 50%;
  display: grid;
  width: 142px;
  height: 112px;
  padding: 8px;
  place-content: center;
  border: 4px solid rgba(91, 74, 232, 0.22);
  border-radius: 32px 32px 25px 25px;
  color: var(--purple-deep);
  background: radial-gradient(circle, #fff 15%, var(--purple-soft) 55%, #d7d0ff 100%);
  box-shadow: 0 0 0 13px rgba(91, 74, 232, 0.07), 0 18px 50px rgba(91, 74, 232, 0.2);
  transform: translate(-50%, -50%);
}

.core-zone.is-charged {
  color: #735600;
  background: radial-gradient(circle, #fff 10%, var(--yellow-soft) 50%, var(--yellow) 100%);
  box-shadow: 0 0 0 18px rgba(255, 212, 92, 0.14), 0 0 70px rgba(255, 212, 92, 0.7);
  animation: core-supercharge 900ms cubic-bezier(.2,.9,.2,1.2) both;
}

.core-zone strong,
.core-zone small {
  position: relative;
  z-index: 2;
  display: block;
}

.core-zone small {
  max-width: 125px;
  margin-top: 5px;
  font-size: 11px;
}

.core-train {
  position: relative;
  z-index: 2;
  display: block;
  font-size: 34px;
  line-height: 1;
}

.core-rings span {
  position: absolute;
  inset: 14px;
  border: 2px dashed currentColor;
  border-radius: 50%;
  opacity: 0.25;
  animation: ring-spin 8s linear infinite;
}

.core-rings span:nth-child(2) { inset: 31px; animation-direction: reverse; animation-duration: 5s; }
.core-rings span:nth-child(3) { inset: 48px; animation-duration: 3.8s; }

@keyframes ring-spin { to { transform: rotate(360deg); } }
@keyframes core-supercharge {
  0% { transform: translate(-50%, -50%) scale(0.78); }
  35% { transform: translate(-50%, -50%) scale(1.14) rotate(-3deg); }
  62% { transform: translate(-50%, -50%) scale(1.06) rotate(3deg); }
  100% { transform: translate(-50%, -50%) scale(1); }
}

.crystal-track {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.crystal-track-shadow,
.crystal-track-base,
.crystal-track-guide,
.crystal-track-active {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.crystal-track-shadow {
  stroke: rgba(47, 42, 97, 0.16);
  stroke-width: 24;
}

.crystal-track-base {
  stroke: #c7c8ec;
  stroke-width: 13;
  stroke-dasharray: 4 13;
  opacity: .42;
}

.crystal-track-guide {
  stroke: #c9cae9;
  stroke-width: 14;
  stroke-dasharray: 5 13;
  opacity: .58;
  transition: stroke 180ms ease, stroke-width 180ms ease, opacity 180ms ease, filter 180ms ease;
}

.crystal-track-guide.is-current {
  stroke: #38c9f2;
  stroke-width: 22;
  stroke-dasharray: 10 8;
  opacity: 1;
  filter: drop-shadow(0 0 5px rgba(56, 201, 242, .95)) drop-shadow(0 0 13px rgba(56, 201, 242, .55));
  animation: current-stroke-glow 1.15s ease-in-out infinite alternate;
}

.crystal-track-guide.is-completed {
  stroke: #f5c84c;
  stroke-width: 14;
  stroke-dasharray: 5 13;
  opacity: .52;
}

.crystal-track-guide.is-upcoming {
  stroke: #c9cae9;
  opacity: .42;
}

.crystal-track-active {
  stroke: url("#trackGradient");
  stroke: var(--yellow);
  stroke-width: 15;
  stroke-dasharray: 0 100;
  filter: drop-shadow(0 0 7px rgba(255, 196, 40, 0.9));
  transition: stroke-dasharray 120ms linear;
}

#crystalTrackArrowGroup {
  pointer-events: none;
}

.crystal-track-direction path {
  fill: none;
  stroke: #716da8;
  stroke-width: 4.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .9;
  filter: drop-shadow(0 1px 1px rgba(255, 255, 255, .75));
}

.crystal-track-direction.is-current path {
  stroke: #087ba8;
  stroke-width: 6;
  opacity: 1;
  filter: drop-shadow(0 0 4px rgba(255,255,255,.95)) drop-shadow(0 0 5px rgba(56,201,242,.8));
}

.crystal-track-direction.is-completed path { stroke: #b68a10; opacity: .58; }
.crystal-track-direction.is-upcoming path { stroke: #8f91b7; opacity: .46; }

@keyframes current-stroke-glow {
  from { opacity: .72; }
  to { opacity: 1; }
}

.track-start-label {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 88%;
  padding: 4px 9px;
  border-radius: 99px;
  color: var(--purple-deep);
  background: rgba(255, 255, 255, 0.82);
  font-size: 11px;
  font-weight: 800;
  transform: translate(-50%, -145%);
}

.crystal-button {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 90%;
  display: grid;
  width: clamp(78px, 11vw, 100px);
  height: clamp(78px, 11vw, 100px);
  place-items: center;
  border: 0;
  border-radius: 28% 72% 38% 62%;
  color: #fff;
  background: linear-gradient(145deg, #8d7cff, var(--purple) 55%, #2d227f);
  box-shadow: 0 18px 30px rgba(91, 74, 232, 0.35), inset 12px 12px 18px rgba(255, 255, 255, 0.23);
  cursor: grab;
  transform: translate(-50%, -50%) rotate(45deg);
  touch-action: none;
  user-select: none;
}

.crystal-button.is-hopping {
  transition: left 360ms cubic-bezier(.2,.9,.2,1.1), top 360ms cubic-bezier(.2,.9,.2,1.1), transform 360ms ease;
}

.crystal-button:active { cursor: grabbing; }

.crystal-button.is-visible {
  opacity: 1;
  visibility: visible;
  filter: drop-shadow(0 0 12px rgba(112, 222, 255, 0.95));
  animation: crystal-ready-pulse 1.45s ease-in-out infinite;
}

@keyframes crystal-ready-pulse {
  0%, 100% { box-shadow: 0 18px 30px rgba(91, 74, 232, 0.35), 0 0 0 0 rgba(99, 216, 255, 0.42), inset 12px 12px 18px rgba(255, 255, 255, 0.23); }
  50% { box-shadow: 0 18px 30px rgba(91, 74, 232, 0.42), 0 0 0 16px rgba(99, 216, 255, 0), inset 12px 12px 18px rgba(255, 255, 255, 0.28); }
}

.crystal-button span {
  font-size: 45px;
  transform: rotate(-45deg);
}

.crystal-button.is-deposited {
  pointer-events: none;
  opacity: 0;
  transition: transform 760ms cubic-bezier(.15,.85,.2,1), opacity 620ms ease, filter 500ms ease;
  filter: brightness(2) drop-shadow(0 0 25px #fff3a1);
  animation: none;
}

.crystal-celebration {
  position: fixed;
  z-index: 90;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.crystal-celebration::before {
  position: absolute;
  inset: 0;
  content: "";
  opacity: 0;
  background: radial-gradient(circle at 50% 55%, rgba(255,255,255,.92), rgba(255,218,79,.24) 24%, transparent 62%);
}

.crystal-celebration.is-active::before {
  animation: celebration-flash 900ms ease-out both;
}

.crystal-celebration span {
  position: absolute;
  left: var(--burst-x);
  top: var(--burst-y);
  width: 12px;
  height: 24px;
  border-radius: 5px;
  background: var(--spark-color, var(--yellow));
  box-shadow: 0 0 14px var(--spark-color, var(--yellow));
  opacity: 0;
}

.badge-celebration span {
  position: absolute;
  width: 10px;
  height: 18px;
  border-radius: 4px;
  background: var(--spark-color, var(--yellow));
  opacity: 0;
}

.crystal-celebration.is-active span {
  animation: crystal-firework 1450ms cubic-bezier(.12,.72,.18,1) var(--spark-delay, 0ms) both;
}

.badge-celebration.is-active span {
  animation: reward-spark 980ms cubic-bezier(.1,.7,.2,1) var(--spark-delay, 0ms) both;
}

@keyframes celebration-flash {
  0% { opacity: 0; }
  14% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes crystal-firework {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.15); }
  12% { opacity: 1; }
  68% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--spark-x)), calc(-50% + var(--spark-y))) rotate(var(--spark-rotate)) scale(.9); }
}

@keyframes reward-spark {
  0% { opacity: 1; transform: rotate(var(--spark-angle)) translateY(0) scale(0.4); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--spark-angle)) translateY(var(--spark-distance)) scale(1); }
}

.completion-message {
  min-height: 30px;
  color: var(--purple-deep);
  font-weight: 800;
}

.letter-voice-button {
  width: min(100%, 560px);
  margin: 12px auto;
  border-color: #cfc8ff;
  color: var(--purple-deep);
  background: linear-gradient(135deg, #fff, var(--purple-soft));
}

.badge-capsule {
  position: relative;
  display: grid;
  width: min(100%, 330px);
  min-height: 250px;
  margin: 32px auto;
  padding: 30px;
  place-items: center;
  border: 0;
  border-radius: 42px;
  color: #fff;
  background: linear-gradient(145deg, var(--purple), #352879);
  box-shadow: 0 25px 60px rgba(63, 49, 159, 0.3);
  cursor: pointer;
}

.badge-stage {
  position: relative;
}

.badge-capsule.is-opening {
  animation: capsule-open-power 680ms cubic-bezier(.2,.8,.2,1) both;
}

@keyframes capsule-open-power {
  0% { transform: rotate(0) scale(1); filter: brightness(1); }
  18% { transform: rotate(-5deg) scale(1.03); }
  36% { transform: rotate(5deg) scale(1.05); }
  55% { transform: rotate(-3deg) scale(1.08); filter: brightness(1.35); }
  100% { transform: scale(0.55); opacity: 0; filter: brightness(2.4); }
}

.badge-celebration {
  position: absolute;
  z-index: 5;
  top: 55%;
  left: 50%;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.badge-celebration::before,
.badge-celebration::after {
  position: absolute;
  top: -160px;
  left: -160px;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  content: "";
  opacity: 0;
  pointer-events: none;
}

.badge-celebration.is-active::before {
  border: 9px solid rgba(255, 213, 72, 0.8);
  animation: badge-shockwave 950ms ease-out both;
}

.badge-celebration.is-active::after {
  background: conic-gradient(from 0deg, transparent 0 8%, rgba(255, 230, 118, 0.48) 8% 12%, transparent 12% 21%);
  animation: badge-rays 1.3s ease-out both;
}

@keyframes badge-shockwave {
  0% { opacity: 1; transform: scale(0.15); }
  100% { opacity: 0; transform: scale(1.25); }
}

@keyframes badge-rays {
  0% { opacity: 0; transform: scale(0.2) rotate(0); }
  35% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.25) rotate(70deg); }
}

.badge-capsule::before,
.badge-capsule::after {
  position: absolute;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  content: "";
}

.badge-capsule::before { top: 30px; left: 30px; }
.badge-capsule::after { right: 24px; bottom: 37px; width: 82px; height: 82px; }

.capsule-lid {
  position: relative;
  z-index: 2;
  display: grid;
  width: 118px;
  height: 118px;
  place-items: center;
  border-radius: 50%;
  color: var(--purple-deep);
  background: var(--yellow);
  box-shadow: 0 0 0 11px rgba(255, 255, 255, 0.13);
  font-size: 54px;
  animation: capsule-wiggle 1.3s ease-in-out infinite;
}

@keyframes capsule-wiggle {
  0%, 100% { transform: rotate(-4deg) scale(1); }
  50% { transform: rotate(4deg) scale(1.04); }
}

.badge-capsule strong {
  position: relative;
  z-index: 2;
  align-self: end;
  font-size: 18px;
}

.awarded-badge {
  animation: badge-pop 700ms cubic-bezier(.2,.9,.2,1.25) both;
}

.awarded-badge.is-super-reveal {
  animation: badge-super-reveal 1100ms cubic-bezier(.15,.9,.2,1.2) both;
}

@keyframes badge-super-reveal {
  0% { opacity: 0; transform: translateY(100px) scale(0.18) rotate(-35deg); filter: brightness(2); }
  45% { opacity: 1; transform: translateY(-18px) scale(1.18) rotate(7deg); }
  72% { transform: translateY(5px) scale(0.96) rotate(-3deg); }
  100% { transform: translateY(0) scale(1) rotate(0); filter: brightness(1); }
}

@keyframes badge-pop {
  from { opacity: 0; transform: scale(0.55) rotate(-15deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}

.badge-medallion {
  position: relative;
  display: grid;
  width: 180px;
  height: 180px;
  margin: 28px auto 20px;
  place-items: center;
  border: 5px solid #fff4bd;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 24%, #ffffff 0 8%, #ffe78c 25%, #7d5be9 68%, #332571 100%);
  box-shadow:
    0 0 0 7px #c7cbd8,
    0 0 0 11px #7f6b28,
    0 0 38px rgba(255, 213, 72, 0.75),
    0 25px 55px rgba(63, 49, 159, 0.32);
}

.badge-medallion::after,
.badge-slot.is-unlocked .mini-medallion::after {
  position: absolute;
  top: 8%;
  left: 18%;
  width: 30%;
  height: 14%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.62);
  content: "";
  filter: blur(1px);
  transform: rotate(-22deg);
}

.badge-art {
  --badge-art-x: 0%;
  --badge-art-y: 0%;
  position: relative;
  left: var(--badge-art-x);
  top: var(--badge-art-y);
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

/* The transparent padding is uneven in several source PNGs. These proportional
   corrections center the visible emblem at every size: album, reveal and zoom. */
.badge-art[src$="zero.png"] { --badge-art-x: 5.5%; }
.badge-art[src$="z.png"] { --badge-art-x: 8%; --badge-art-y: -5.5%; }
.badge-art[src$="mebius.png"] { --badge-art-y: 5.1%; }
.badge-art[src$="orb.png"] { --badge-art-y: 5.1%; }
.badge-art[src$="geed.png"] { --badge-art-x: 5.5%; --badge-art-y: 5.3%; }
.badge-art[src$="blazar.png"] { --badge-art-y: 5.3%; }
.badge-art[src$="beta-capsule.png"] { --badge-art-x: -7%; --badge-art-y: 8%; }
.badge-art[src$="zero-eye.png"] { --badge-art-x: 5.9%; }
.badge-art[src$="orb-ring.png"] { --badge-art-x: 8.2%; --badge-art-y: 7.6%; }

.badge-art-large {
  width: 166px;
  height: 166px;
  animation: badge-energy-pulse 1.8s ease-in-out 2;
}

@keyframes badge-energy-pulse {
  0%, 100% { filter: drop-shadow(0 0 3px rgba(255, 230, 112, 0.35)); transform: scale(1); }
  50% { filter: drop-shadow(0 0 14px rgba(255, 230, 112, 0.95)); transform: scale(1.035); }
}

.album-count {
  display: flex;
  align-items: baseline;
  gap: 4px;
  color: var(--purple);
}

.album-count strong { font-size: 34px; }
.album-count span { color: var(--muted); }

.album-progress-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.album-progress-panel p {
  max-width: 360px;
  margin-bottom: 0;
  color: var(--muted);
}

.album-book-tabs {
  display: flex;
  gap: 14px;
  margin-top: var(--sp-4);
  padding: 4px 4px 12px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
}

.album-book-tab,
.album-book-placeholder {
  position: relative;
  display: grid;
  width: clamp(132px, 25vw, 168px);
  min-width: clamp(132px, 25vw, 168px);
  aspect-ratio: 3 / 4;
  min-height: 0;
  grid-template-rows: 1fr auto;
  justify-items: center;
  gap: 5px;
  padding: 19px 12px 14px 23px;
  overflow: hidden;
  border: 2px solid rgba(113, 97, 214, .25);
  border-radius: 8px 18px 18px 8px;
  color: var(--ink);
  background: linear-gradient(135deg, #f7f5ff, #e2ddff);
  box-shadow: inset 7px 0 rgba(255,255,255,.48), 0 8px 18px rgba(70, 53, 159, .12);
  font: inherit;
  text-align: center;
  scroll-snap-align: start;
}

.album-book-tab {
  cursor: pointer;
}

.album-book-spine {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 17px;
  border-radius: 6px 0 0 6px;
  background: linear-gradient(90deg, #30266d, #7568df 58%, #b9b1ff);
  box-shadow: inset -2px 0 rgba(255,255,255,.36), 3px 0 5px rgba(45,31,119,.18);
}

.album-book-cover-art {
  display: grid;
  width: 88px;
  height: 88px;
  place-items: center;
  border: 2px solid rgba(255,255,255,.68);
  border-radius: 50%;
  object-fit: cover;
  overflow: hidden;
  background: radial-gradient(circle at 35% 25%, #fff8bd, #e7bc45 47%, #5d48e7 100%);
  box-shadow: 0 5px 14px rgba(48, 37, 128, .24);
  font-size: 43px;
}

.album-book-cover-art img { width: 100%; height: 100%; object-fit: cover; }
.album-book-copy { display: grid; gap: 3px; }
.album-book-tab strong { font-size: 16px; }
.album-book-tab small { color: var(--muted); font-weight: 800; }
.album-book-tab.is-selected { border-color: #6250ea; background: linear-gradient(135deg, #fffdf4, #d8f2ff); box-shadow: 0 0 0 4px rgba(91,74,232,.13), inset 7px 0 rgba(255,255,255,.65), 0 10px 22px rgba(91, 74, 232, .22); }
.album-book-tab.is-locked { opacity: .56; filter: grayscale(.72); cursor: not-allowed; }
.album-book-tab:not(:disabled):active { transform: scale(.98); }
.album-book-placeholder { border-color: #d6d8e3; color: #8b91a6; background: linear-gradient(135deg, #f3f4f8, #e3e5ec); box-shadow: inset 7px 0 rgba(255,255,255,.6), 0 6px 13px rgba(75,78,104,.09); }
.album-book-placeholder .album-book-spine { background: linear-gradient(90deg, #8b90a1, #c2c5cf 58%, #e1e3e9); }
.album-book-placeholder .album-book-cover-art { color: #a0a5b6; background: radial-gradient(circle at 35% 25%, #fff, #d9dce5 55%, #a3a8b8 100%); filter: grayscale(1); }
.album-book-placeholder small { color: #9aa0b0; }

.badge-symbol {
  display: grid;
  width: 90%;
  height: 90%;
  place-items: center;
  font-size: 44px;
  line-height: 1;
  filter: drop-shadow(0 2px 3px rgba(55, 32, 113, .28));
}

.badge-sprite {
  display: block;
  width: 100%;
  height: 100%;
  background-image: url("assets/badges/kaiju-badges-v1.png");
  background-repeat: no-repeat;
  background-size: 400% 300%;
  background-position: var(--sprite-x) var(--sprite-y);
}

.badge-sprite-svg {
  overflow: hidden;
}

.badge-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-3);
  margin-top: var(--sp-4);
}

.badge-slot {
  position: relative;
  display: grid;
  min-height: 148px;
  padding: 14px 8px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--r-lg);
  text-align: center;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  appearance: none;
}

.badge-slot:active { transform: scale(.97); }
.badge-slot:focus-visible { outline: 4px solid rgba(91, 74, 232, .28); outline-offset: 3px; }

.badge-slot .mini-medallion {
  position: relative;
  display: grid;
  overflow: hidden;
  width: 78px;
  height: 78px;
  place-items: center;
  border: 3px solid #f8e8a0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 25%, #fffde1, #d6b845 45%, #5a43bd 100%);
  box-shadow:
    0 0 0 3px #bdc2cf,
    0 0 0 5px #6c5a24,
    0 8px 18px rgba(49, 39, 112, 0.22);
}

.badge-slot .mini-medallion .badge-art {
  position: relative;
  width: 90%;
  height: 90%;
  margin: auto;
  object-position: 50% 50%;
}

.badge-slot .mini-medallion .badge-symbol { margin: auto; }

.badge-slot.is-unlocked {
  border-color: rgba(255, 201, 56, 0.72);
  background:
    radial-gradient(circle at 50% 28%, rgba(255, 231, 121, 0.32), transparent 46%),
    rgba(255, 255, 255, 0.92);
}

.badge-slot.is-unlocked .mini-medallion {
  border-color: #fff0a8;
  background: radial-gradient(circle at 35% 25%, #fffde8 0 10%, #ffd45c 35%, #7a55e6 72%, #332571 100%);
  box-shadow:
    0 0 0 3px #d9b446,
    0 0 0 5px #7f6420,
    0 0 17px rgba(255, 214, 72, 0.85),
    0 8px 18px rgba(49, 39, 112, 0.22);
}

.badge-slot.is-unlocked .badge-art {
  animation: badge-light-up 720ms cubic-bezier(.2,.9,.2,1.2) both;
  opacity: 1;
  filter: saturate(1.3) contrast(1.08) brightness(1.08) drop-shadow(0 0 6px rgba(255, 222, 82, 0.7));
}

@keyframes badge-light-up {
  from { opacity: 0.4; filter: grayscale(1) brightness(0.7); transform: scale(0.78) rotate(-8deg); }
  to { opacity: 1; filter: saturate(1.08) contrast(1.03) drop-shadow(0 0 6px rgba(255, 222, 82, 0.58)); transform: scale(1) rotate(0); }
}

.badge-slot.is-newly-earned {
  border-color: var(--yellow);
  background: radial-gradient(circle at 50% 35%, rgba(255, 231, 100, 0.55), rgba(255,255,255,.96) 64%);
  animation: new-badge-slot-flash 1.15s ease-in-out infinite alternate;
}

.badge-slot.is-newly-earned::after {
  position: absolute;
  top: 7px;
  right: 7px;
  padding: 3px 6px;
  border-radius: 999px;
  color: #5a4100;
  background: var(--yellow);
  box-shadow: 0 2px 7px rgba(115, 82, 0, 0.25);
  content: "新";
  font-size: 10px;
  font-weight: 900;
}

.badge-slot.is-newly-earned .mini-medallion {
  animation: new-badge-medallion 900ms ease-in-out infinite alternate;
}

@keyframes new-badge-slot-flash {
  from { box-shadow: 0 0 0 0 rgba(255, 211, 71, 0.12); }
  to { box-shadow: 0 0 0 8px rgba(255, 211, 71, 0.38), 0 10px 22px rgba(91, 74, 232, 0.16); }
}

@keyframes new-badge-medallion {
  from { transform: scale(1) rotate(-2deg); filter: brightness(1); }
  to { transform: scale(1.1) rotate(2deg); filter: brightness(1.18) drop-shadow(0 0 8px rgba(255, 215, 75, 0.9)); }
}

.badge-slot strong {
  display: block;
  font-size: 12px;
  line-height: 1.3;
}

.badge-slot > small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.badge-slot.is-locked {
  color: #9ba1b8;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: none;
}

.badge-detail-dialog {
  width: min(92vw, 520px);
  overflow: visible;
  text-align: center;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 225, 95, .3), transparent 40%),
    linear-gradient(180deg, #fff, #f4f1ff);
}

.badge-detail-dialog form { display: grid; place-items: center; }

.badge-detail-art {
  position: relative;
  display: grid;
  width: min(58vw, 280px);
  aspect-ratio: 1;
  margin: 18px auto 14px;
  padding: 24px;
  place-items: center;
  border: 8px solid #ffe06a;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 25%, #fffde1, #d6b845 42%, #5a43bd 100%);
  box-shadow: 0 0 0 8px #c8ccd7, 0 0 0 13px #7a6424, 0 22px 55px rgba(53, 39, 136, .34), 0 0 70px rgba(255, 213, 72, .62);
}

.badge-detail-art::after {
  position: absolute;
  top: 12%;
  left: 20%;
  width: 31%;
  height: 14%;
  border-radius: 50%;
  background: rgba(255,255,255,.65);
  content: "";
  transform: rotate(-24deg);
}

.badge-detail-art.is-locked { filter: grayscale(1) brightness(.72); box-shadow: 0 0 0 8px #d8dbe4, 0 15px 35px rgba(50,50,75,.2); }
.badge-detail-image { width: 100%; height: 100%; animation: badge-detail-float 2s ease-in-out infinite; }
.badge-detail-art.is-locked .badge-detail-image { opacity: .58; animation: none; }

@keyframes badge-detail-float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-7px) scale(1.035); }
}

.badge-detail-status {
  padding: 6px 13px;
  border-radius: 99px;
  color: #755500;
  background: var(--yellow-soft);
  font-size: 12px;
  font-weight: 900;
}

.badge-detail-dialog h2 { margin: 12px 0 4px; font-size: clamp(26px, 5vw, 38px); }
.badge-detail-dialog p { max-width: 390px; color: var(--muted); font-size: 16px; }

.family-sync-panel {
  background:
    radial-gradient(circle at 92% 8%, rgba(99, 216, 255, .22), transparent 35%),
    linear-gradient(145deg, rgba(255,255,255,.95), rgba(239,237,255,.95));
}

.family-sync-panel > p { color: var(--muted); }
.sync-cloud-icon { font-size: 38px; filter: drop-shadow(0 7px 9px rgba(91,74,232,.2)); }
.sync-code-input { letter-spacing: .12em; text-transform: uppercase; font-weight: 900; }
.sync-status { padding: 10px 12px; border-radius: 14px; color: var(--purple-deep) !important; background: rgba(255,255,255,.78); font-weight: 800; }
.sync-actions { flex-wrap: wrap; }
.sync-actions button { min-height: 48px; }
.sync-note { display: block; margin-top: 12px; color: var(--muted); line-height: 1.55; }

.game-library-panel { background: linear-gradient(145deg, rgba(255,255,255,.97), rgba(247,244,255,.96)); }
.game-library-note { margin: 0 0 12px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.game-library-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-items: start; }
.library-group { min-width: 0; }
.library-group { border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: rgba(255,255,255,.55); }
.library-group summary { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; color: var(--ink); font-weight: 900; cursor: pointer; }
.library-group summary small { color: var(--muted); font-weight: 700; }
.library-group-list { display: grid; gap: 7px; padding: 0 7px 7px; }
.game-library-item { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 9px; align-items: center; padding: 9px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel-soft); }
.game-library-item.is-paused { opacity: .62; background: #f1f2f6; }
.game-library-icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 13px; background: #fff; font-size: 24px; }
.game-library-copy { min-width: 0; padding: 0; border: 0; text-align: left; background: transparent; cursor: pointer; }
.game-library-copy strong, .game-library-copy small { display: block; }
.game-library-copy strong { color: var(--ink); font-size: 14px; }
.game-library-copy small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.game-library-actions { display: flex; gap: 6px; }
.game-library-actions button { display: grid; width: 42px; height: 42px; place-items: center; border: 1px solid var(--line); border-radius: 13px; background: #fff; color: var(--purple-deep); font-size: 21px; cursor: pointer; }
.game-library-actions button[aria-pressed="true"] { border-color: var(--purple); background: var(--purple-soft); box-shadow: 0 4px 10px rgba(91,74,232,.14); }
.library-preview-steps { margin: 12px 0; padding-left: 22px; text-align: left; line-height: 1.6; }
.library-preview-dialog #libraryPreviewGoal, .library-preview-dialog #libraryPreviewEasy { text-align: left; color: var(--muted); }

@media (max-width: 599px) {
  .game-library-list { grid-template-columns: 1fr; }
}

.badge-slot.is-locked .mini-medallion {
  border-color: #d9dce5;
  background: #e9ebf1;
  box-shadow: 0 0 0 3px #c9cdd8;
}

.badge-slot.is-locked .badge-art {
  opacity: 0.42;
  filter: grayscale(1) brightness(0.68) contrast(0.82);
}

.badge-slot.is-forged::after {
  position: absolute;
  top: 7px;
  right: 7px;
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: var(--r-full);
  background: var(--yellow-soft);
  box-shadow: var(--shadow-1);
  content: "🔥";
  font-size: 13px;
}

.forge-panel {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) minmax(230px, 0.75fr);
  gap: var(--sp-4);
  align-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 8% 20%, rgba(255, 212, 92, 0.24), transparent 150px),
    linear-gradient(135deg, rgba(255,255,255,.97), rgba(238,234,255,.94));
}

.forge-panel.is-ready {
  outline: 2px solid rgba(255, 182, 47, 0.55);
  outline-offset: -2px;
}

.forge-panel-icon {
  display: grid;
  width: 72px;
  height: 72px;
  place-items: center;
  border-radius: 22px;
  background: linear-gradient(145deg, var(--yellow-soft), var(--purple-soft));
  font-size: 38px;
}

.forge-panel-copy h2,
.forge-panel-copy p {
  margin: 0;
}

.forge-panel-copy p {
  margin-top: var(--sp-1);
  color: var(--muted);
  font-size: 13px;
}

.forge-open-button {
  min-height: 72px;
}

.forge-stage {
  position: relative;
  width: min(100%, 820px);
  margin: 0 auto;
  padding-bottom: 28px;
}

.forge-stage > h1 {
  max-width: 720px;
}

.forge-stage > .lead {
  max-width: 680px;
}

.forge-count {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  margin: var(--sp-3) 0;
  padding: 7px 13px;
  border-radius: var(--r-full);
  color: var(--purple-deep);
  background: var(--purple-soft);
}

.forge-count span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.forge-selection-grid {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--sp-2);
  margin: var(--sp-2) 0 var(--sp-4);
}

.forge-badge-choice {
  display: grid;
  min-width: 0;
  min-height: 126px;
  padding: 10px 5px;
  place-items: center;
  border: 2px solid transparent;
  border-radius: var(--r-lg);
  color: var(--ink);
  background: rgba(255,255,255,.86);
  cursor: pointer;
}

.forge-badge-choice.is-selected {
  border-color: var(--purple);
  background: var(--purple-soft);
  box-shadow: 0 0 0 3px rgba(91,74,232,.1);
}

.forge-badge-choice .mini-medallion {
  display: grid;
  overflow: hidden;
  width: 64px;
  height: 64px;
  place-items: center;
  border: 3px solid #f4dda0;
  border-radius: 50%;
  background: #e9ebf1;
  box-shadow: 0 0 0 3px #c9cdd8;
}

.forge-badge-choice .badge-art {
  width: 90%;
  height: 90%;
  object-fit: contain;
}

.forge-badge-choice strong,
.forge-badge-choice small {
  display: block;
  overflow: hidden;
  width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.forge-badge-choice strong { font-size: 11px; }
.forge-badge-choice small { color: var(--muted); font-size: 9px; font-weight: 700; }

.furnace-stage {
  position: relative;
  width: min(100%, 620px);
  height: 300px;
  margin: 0 auto var(--sp-3);
  overflow: hidden;
  border-radius: 30px;
  background:
    radial-gradient(circle at 50% 72%, rgba(255, 199, 63, .3), transparent 32%),
    radial-gradient(circle at 50% 58%, rgba(91, 74, 232, .2), transparent 54%),
    linear-gradient(180deg, #f8f4ff, #e7e3ff);
}

.magic-aura {
  position: absolute;
  left: 50%;
  bottom: 8px;
  width: 260px;
  height: 260px;
  border: 3px dashed rgba(91,74,232,.24);
  border-radius: 50%;
  transform: translateX(-50%);
}

.magic-furnace {
  position: absolute;
  bottom: 18px;
  left: 50%;
  width: 190px;
  height: 205px;
  transform: translateX(-50%);
}

.furnace-chimney {
  position: absolute;
  top: 0;
  left: 65px;
  width: 60px;
  height: 52px;
  border: 6px solid var(--purple-deep);
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
  background: #8579f4;
}

.furnace-body {
  position: absolute;
  right: 0;
  bottom: 12px;
  left: 0;
  display: grid;
  height: 155px;
  place-items: center;
  border: 7px solid var(--purple-deep);
  border-radius: 48px 48px 34px 34px;
  background: linear-gradient(145deg, #8c7eff, #5140c2);
  box-shadow: inset 0 0 0 6px rgba(255,255,255,.16), 0 12px 24px rgba(63,49,159,.2);
}

.furnace-body b {
  position: absolute;
  top: 18px;
  color: var(--yellow);
  font-size: 25px;
}

.furnace-mouth {
  display: grid;
  width: 88px;
  height: 74px;
  margin-top: 32px;
  place-items: center;
  border: 6px solid #2e246f;
  border-radius: 38px 38px 24px 24px;
  background: #1f194d;
  box-shadow: inset 0 0 25px rgba(255,113,104,.5);
  font-size: 42px;
  font-style: normal;
}

.furnace-feet::before,
.furnace-feet::after {
  position: absolute;
  bottom: 0;
  width: 42px;
  height: 25px;
  border-radius: 0 0 14px 14px;
  background: var(--purple-deep);
  content: "";
}

.furnace-feet::before { left: 24px; }
.furnace-feet::after { right: 24px; }

.forge-offerings {
  position: absolute;
  z-index: 4;
  top: 22px;
  left: 50%;
  display: grid;
  width: min(92%, 430px);
  grid-template-columns: repeat(5, 1fr);
  gap: var(--sp-2);
  transform: translateX(-50%);
}

.forge-offering {
  display: grid;
  width: 58px;
  height: 58px;
  margin: auto;
  place-items: center;
  overflow: hidden;
  border: 3px solid #fff0a8;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 6px 15px rgba(48,48,110,.16);
}

.forge-offering .badge-art { width: 92%; height: 92%; object-fit: contain; }

.magic-smoke i {
  position: absolute;
  bottom: 200px;
  left: 50%;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.8);
  opacity: .45;
}

.magic-smoke i:nth-child(1) { margin-left: -46px; }
.magic-smoke i:nth-child(2) { width: 48px; height: 48px; margin-left: -10px; bottom: 214px; }
.magic-smoke i:nth-child(3) { margin-left: 28px; bottom: 202px; }

.forge-screen.is-forging .magic-furnace,
#forgeScreen.is-forging .magic-furnace {
  animation: furnace-shake 430ms ease-in-out infinite;
}

#forgeScreen.is-forging .magic-aura {
  animation: furnace-aura 850ms linear infinite;
}

#forgeScreen.is-forging .furnace-mouth {
  animation: furnace-fire 360ms ease-in-out infinite alternate;
}

#forgeScreen.is-forging .forge-offering {
  animation: badge-into-furnace 900ms cubic-bezier(.4,.05,.75,.45) forwards;
  animation-delay: calc(var(--forge-index) * 170ms);
}

#forgeScreen.is-forging .magic-smoke i {
  animation: magic-smoke-rise 1s ease-out infinite;
}

@keyframes badge-into-furnace {
  0% { opacity: 1; transform: translate(0,0) scale(1) rotate(0); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--forge-x), 174px) scale(.18) rotate(380deg); }
}

@keyframes furnace-shake {
  0%,100% { transform: translateX(-50%) rotate(-1deg); }
  50% { transform: translateX(-50%) rotate(1deg) scale(1.02); }
}

@keyframes furnace-aura {
  to { transform: translateX(-50%) rotate(360deg); }
}

@keyframes furnace-fire {
  from { filter: brightness(1); transform: scale(.96); }
  to { filter: brightness(1.45); transform: scale(1.08); }
}

@keyframes magic-smoke-rise {
  from { opacity: .55; transform: translateY(0) scale(.7); }
  to { opacity: 0; transform: translateY(-80px) scale(1.5); }
}

.forge-result {
  width: 100%;
  margin-top: var(--sp-5);
  text-align: center;
}

.forge-result h2 { margin: 0 0 var(--sp-4); }

.forge-result-games {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--sp-2);
  margin-bottom: var(--sp-5);
}

.forged-game-card {
  display: grid;
  min-height: 130px;
  padding: var(--sp-3) var(--sp-2);
  place-items: center;
  border-radius: var(--r-lg);
  background: #fff;
  box-shadow: var(--shadow-1);
  animation: forged-game-reveal 700ms cubic-bezier(.2,.9,.2,1.15) both;
  animation-delay: calc(var(--reveal-index) * 130ms);
}

.forged-game-card > span { font-size: 38px; }
.forged-game-card strong { font-size: 12px; line-height: 1.25; }
.forged-game-card small { color: var(--muted); font-size: 9px; font-weight: 700; }

@keyframes forged-game-reveal {
  from { opacity: 0; transform: translateY(35px) rotateY(90deg) scale(.7); }
  to { opacity: 1; transform: translateY(0) rotateY(0) scale(1); }
}

.forge-celebration {
  position: fixed;
  z-index: 35;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.forge-celebration span {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 9px;
  height: 18px;
  border-radius: 3px;
  background: var(--spark-color);
  opacity: 0;
}

.forge-celebration.is-active span {
  animation: reward-spark 1100ms cubic-bezier(.2,.75,.2,1) var(--spark-delay) both;
  transform: rotate(var(--spark-angle));
}

.route-progress {
  overflow: hidden;
  height: 12px;
  border-radius: 99px;
  background: var(--line);
}

.route-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--purple), var(--sky));
  transition: width 500ms ease;
}

.route-panel p {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.settings-panel {
  display: grid;
  gap: 10px;
}

.voice-test-box {
  display: grid;
  gap: 8px;
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.voice-test-status {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.field-label {
  margin: 6px 0 0;
}

.text-input {
  width: 100%;
  min-height: 50px;
  padding: 11px 14px;
  border: 1px solid #cfd4e9;
  border-radius: var(--r-md);
  color: var(--ink);
  background: #fff;
}

.reward-item,
.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}

.reward-item:first-child,
.history-item:first-child { border-top: 0; }

.reward-item strong,
.reward-item small,
.history-item strong,
.history-item small { display: block; }

.reward-item small,
.history-item small { color: var(--muted); }

.history-empty {
  margin: 0;
  color: var(--muted);
}

.details-panel summary {
  cursor: pointer;
  font-weight: 800;
}

.details-panel p {
  margin: 14px 0;
  color: var(--muted);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.file-button {
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}

.danger-link {
  margin-top: 22px;
  padding: 5px 0;
  color: #b7313c;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.bottom-nav {
  position: fixed;
  z-index: 30;
  right: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom));
  display: grid;
  width: min(calc(100% - 28px), 540px);
  grid-template-columns: repeat(3, 1fr);
  padding: var(--sp-1);
  border: 1px solid rgba(223, 227, 245, 0.9);
  border-radius: var(--r-xl);
  background: rgba(248, 249, 255, 0.94);
  box-shadow: var(--shadow-2);
  backdrop-filter: blur(16px);
  transform: translateX(50%);
}

.bottom-nav button {
  display: grid;
  min-height: 66px;
  padding: 5px;
  place-items: center;
  border: 0;
  border-radius: var(--r-lg);
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.bottom-nav button span {
  font-size: 27px;
  line-height: 1;
}
.bottom-nav button strong { font-size: 12px; }

.bottom-nav button.is-active {
  color: var(--purple-deep);
  background: #fff;
  box-shadow: var(--shadow-1);
}

/* Kid-first touch targets: game controls are visual tiles, not text strips. */
#homeScreen #prepareDrawButton {
  display: grid;
  width: 100%;
  margin-inline: 0;
  min-height: 158px;
  padding: 18px;
  place-items: center;
  text-align: center;
}

#homeScreen #prepareDrawButton .kid-action-icon {
  width: 82px;
  height: 82px;
  border-radius: 26px;
  font-size: 48px;
}

#homeScreen #prepareDrawButton .kid-action-copy strong { font-size: 22px; }
#homeScreen #prepareDrawButton .kid-action-copy small { display: none; }

#homeScreen .setup-draw-panel #prepareDrawButton {
  flex: 1 1 auto;
  min-height: 250px;
  padding: 18px 12px;
  border-radius: 26px;
  background:
    radial-gradient(circle at 75% 18%, rgba(255, 225, 112, 0.32), transparent 30%),
    linear-gradient(155deg, #6554ef, #4032b9);
}

#homeScreen .setup-draw-panel #prepareDrawButton .kid-action-icon {
  width: 94px;
  height: 94px;
  border-radius: 30px;
  font-size: 55px;
  background: rgba(255, 255, 255, 0.18);
}

#homeScreen .setup-draw-panel #prepareDrawButton .kid-action-copy strong {
  color: #fff;
  font-size: clamp(23px, 3vw, 32px);
  line-height: 1.15;
}

#homeScreen .setup-draw-panel #prepareDrawButton .kid-action-copy small {
  display: block;
  margin-top: 7px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
}

.game-topline {
  grid-template-columns: 72px 1fr 72px;
}

.game-topline .kid-icon-button {
  width: 72px;
  height: 72px;
  border-radius: 24px;
  font-size: 35px;
}

.step-arrow {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  font-size: 42px;
}

.sound-command {
  min-height: 122px;
  border-radius: 22px;
}

.sound-command span { font-size: 42px; }
.sound-command strong { font-size: 16px; }

.demo-replay {
  min-height: 58px;
  border-radius: 18px;
  font-size: 16px;
}

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

.game-actions .kid-action,
.completion-action-grid .kid-action,
#badgeRevealScreen #badgeContinueButton,
#forgeScreen #forgeStartButton,
#forgeScreen #forgeContinueButton,
#albumScreen .forge-open-button {
  display: grid;
  width: 100%;
  margin-inline: 0;
  min-height: 156px;
  padding: 16px 10px;
  place-items: center;
  border-radius: 28px;
  text-align: center;
}

.game-actions .kid-action .kid-action-icon,
.completion-action-grid .kid-action .kid-action-icon,
#badgeRevealScreen #badgeContinueButton .kid-action-icon,
#forgeScreen .kid-action .kid-action-icon,
#albumScreen .forge-open-button .kid-action-icon {
  width: 78px;
  height: 78px;
  flex-basis: 78px;
  border-radius: 24px;
  font-size: 44px;
}

.game-actions .kid-action .kid-action-copy,
.completion-action-grid .kid-action .kid-action-copy,
#badgeRevealScreen #badgeContinueButton .kid-action-copy,
#forgeScreen .kid-action .kid-action-copy,
#albumScreen .forge-open-button .kid-action-copy {
  margin-top: 8px;
}

.game-actions .kid-action .kid-action-copy strong,
.completion-action-grid .kid-action .kid-action-copy strong,
#badgeRevealScreen #badgeContinueButton .kid-action-copy strong,
#forgeScreen .kid-action .kid-action-copy strong,
#albumScreen .forge-open-button .kid-action-copy strong { font-size: 19px; }

.game-actions .kid-action .kid-action-copy small,
.completion-action-grid .kid-action .kid-action-copy small,
#badgeRevealScreen #badgeContinueButton .kid-action-copy small,
#forgeScreen .kid-action .kid-action-copy small,
#albumScreen .forge-open-button .kid-action-copy small { display: none; }

.game-actions .is-crystal-picture {
  grid-column: 1 / -1;
  min-height: 182px;
}

.completion-action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  width: min(100%, 560px);
  margin: 16px auto 0;
}

.completion-action-grid [hidden] { display: none !important; }

/* The final two actions stay on screen after the tall letter track is complete. */
.completion-action-grid.is-ready {
  position: fixed;
  z-index: 85;
  right: 50%;
  bottom: calc(86px + env(safe-area-inset-bottom));
  width: min(560px, calc(100vw - 28px));
  margin: 0;
  padding: 10px;
  border: 1px solid rgba(91, 74, 232, 0.22);
  border-radius: 30px;
  background: rgba(248, 249, 255, 0.96);
  box-shadow: 0 16px 34px rgba(50, 41, 134, 0.24);
  backdrop-filter: blur(14px);
  transform: translateX(50%);
}

.completion-action-grid.is-ready .kid-action { min-height: 132px; }

#badgeRevealScreen #badgeContinueButton,
#forgeScreen #forgeStartButton,
#forgeScreen #forgeContinueButton {
  width: min(100%, 320px);
  margin: 18px auto 0;
}

#albumScreen .forge-open-button { min-height: 144px; }

#rerouteDialog .dialog-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#rerouteDialog .dialog-kid-action {
  display: grid;
  width: 100%;
  margin-inline: 0;
  min-height: 148px;
  padding: 14px 8px;
  place-items: center;
  border-radius: 25px;
  text-align: center;
}

#rerouteDialog .dialog-kid-action .kid-action-icon {
  width: 68px;
  height: 68px;
  flex-basis: 68px;
  border-radius: 22px;
  font-size: 40px;
}

#rerouteDialog .dialog-kid-action .kid-action-copy { margin-top: 8px; }
#rerouteDialog .dialog-kid-action .kid-action-copy small { display: none; }
#rerouteDialog .text-button { grid-column: 1 / -1; }

.rescue-options button {
  min-height: 132px;
  border-radius: 24px;
}

.rescue-options button span { font-size: 43px; }
.rescue-options button strong { margin-top: 5px; font-size: 15px; }
.rescue-options button small { display: none; }

.app-dialog {
  width: min(calc(100% - 28px), 500px);
  max-height: calc(100dvh - 24px);
  padding: clamp(22px, 6vw, 34px);
  border: 0;
  border-radius: var(--r-xl);
  color: var(--ink);
  background: #fff;
  box-shadow: 0 18px 56px rgba(26, 26, 72, 0.28);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.app-dialog::backdrop {
  background: rgba(23, 21, 55, 0.58);
  backdrop-filter: blur(5px);
}

.app-dialog form {
  display: grid;
  text-align: center;
}

.app-dialog p {
  color: var(--muted);
}

.dialog-icon {
  margin-bottom: 8px;
  font-size: 48px;
}

.dialog-actions,
.rescue-options {
  display: grid;
  gap: 10px;
}

.dialog-kid-action {
  min-height: 78px;
}

.dialog-kid-action .kid-action-icon {
  flex-basis: 50px;
  width: 50px;
  height: 50px;
  font-size: 27px;
}

.text-button {
  min-height: 44px;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.rescue-options {
  grid-template-columns: repeat(2, 1fr);
  margin: 8px 0;
}

.rescue-options button {
  display: grid;
  min-height: 112px;
  padding: 12px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-soft);
  cursor: pointer;
}

.rescue-options button span { font-size: 28px; }
.rescue-options button strong,
.rescue-options button small { display: block; }
.rescue-options button small { color: var(--muted); font-size: 11px; }
.rescue-options button:disabled { background: #f2f3f7; }

.pause-time {
  margin: 12px 0 20px;
  color: var(--purple);
  font-size: 54px;
  font-variant-numeric: tabular-nums;
}

.toast {
  position: fixed;
  z-index: 100;
  right: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom));
  width: max-content;
  max-width: calc(100% - 36px);
  padding: 12px 16px;
  border-radius: 15px;
  color: #fff;
  background: rgba(32, 38, 83, 0.94);
  box-shadow: var(--shadow);
  text-align: center;
  transform: translateX(50%);
}

@media (max-width: 620px) {
  .app-shell {
    padding-right: 13px;
    padding-left: 13px;
  }

  .hero-card {
    border-radius: 27px;
  }

  .train-scene {
    height: 158px;
  }

  .train {
    right: 1%;
    transform-origin: right bottom;
    scale: 0.86;
  }

  .monster-one { left: 1%; }
  .monster-two { right: 37%; }

  .journey-status {
    gap: 8px;
    padding: 13px 12px;
  }

  .journey-status strong {
    font-size: 13px;
  }

  .mode-grid,
  .switch-row {
    grid-template-columns: 1fr;
  }

  .palm-button {
    min-height: 195px;
    border-radius: 24px;
  }

  .badge-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 9px;
  }

  .badge-slot {
    min-height: 136px;
    border-radius: 18px;
  }

  .album-progress-panel {
    display: block;
  }

  .album-progress-panel p {
    margin-top: 15px;
  }

  .forge-panel {
    grid-template-columns: 58px minmax(0, 1fr);
    gap: var(--sp-3);
  }

  .forge-panel-icon {
    width: 58px;
    height: 58px;
    border-radius: var(--r-lg);
    font-size: 31px;
  }

  .forge-open-button {
    grid-column: 1 / -1;
  }

  .forge-selection-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .forge-badge-choice {
    min-height: 118px;
  }

  .furnace-stage {
    height: 285px;
  }

  .forge-offerings {
    width: 96%;
    gap: 2px;
  }

  .forge-offering {
    width: 48px;
    height: 48px;
  }

  .forge-result-games {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 380px) {
  h1 { font-size: 27px; }

  .hero-card,
  .panel,
  .game-guide,
  .reveal-stage {
    border-radius: 23px;
  }

  .journey-status {
    align-items: flex-start;
  }

  .status-label { font-size: 10px; }

  .palm-grid { gap: 8px; }
  .palm-button { min-height: 176px; padding: 16px 6px; }
  .palm-button strong { font-size: 15px; }

  .kid-action {
    min-height: 78px;
    gap: 11px;
    padding: 10px 12px;
  }

  .kid-action-icon {
    flex-basis: 50px;
    width: 50px;
    height: 50px;
    font-size: 27px;
  }

  .kid-action-copy strong { font-size: 17px; }

  .game-topline {
    grid-template-columns: 52px 1fr 52px;
    gap: 6px;
  }

  .game-topline .kid-icon-button {
    width: 52px;
    height: 52px;
  }

  .step-navigator {
    grid-template-columns: 28px minmax(60px, 1fr) 28px;
    gap: 2px;
  }

  .step-arrow {
    width: 28px;
    height: 40px;
    font-size: 26px;
  }

  .step-navigator-center small {
    font-size: 11px;
  }

  .game-timer-panel {
    padding: 7px 9px;
  }

  .game-timer-display {
    grid-template-columns: 40px auto 1fr;
  }

  .game-timer-note {
    max-width: 90px;
  }

  .countdown-options button {
    padding: 6px 2px;
    font-size: 12px;
  }

  .badge-grid { grid-template-columns: repeat(2, 1fr); }

  .rescue-options { grid-template-columns: 1fr 1fr; }
  .rescue-options button { min-height: 105px; }
}

/* ConVoice interaction principles: selected state is explicit, hover stays
   quiet, and shadow is reserved for controls that actually rise. */
@media (hover: hover) and (pointer: fine) {
  .mode-option:not(.is-selected):hover,
  .timer-mode-option:not(.is-selected):hover,
  .switch-control:hover,
  .badge-slot:hover {
    border-color: var(--line);
  }

  .primary-button:hover {
    filter: brightness(0.94);
  }

  .secondary-button:hover,
  .bottom-nav button:not(.is-active):hover {
    color: var(--purple-deep);
  }
}

/* iPad / large tablet portrait: keep each main screen inside one viewport. */
@media (min-width: 99999px) and (min-height: 99999px) {
  body[data-screen="home"],
  body[data-screen="album"],
  body[data-screen="parent"] {
    overflow: hidden;
  }

  .app-shell {
    width: min(100%, 1200px);
    height: 100svh;
    min-height: 0;
    padding: 0 20px calc(78px + env(safe-area-inset-bottom));
  }

  .topbar {
    padding: calc(7px + env(safe-area-inset-top)) 0 7px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 13px;
  }

  .brand-copy strong {
    font-size: 14px;
  }

  .brand-copy span {
    font-size: 10px;
  }

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

  .screen {
    padding: 6px 0 8px;
  }

  .bottom-nav {
    bottom: 7px;
    padding: 5px;
  }

  .bottom-nav button {
    min-height: 57px;
    padding: 5px 10px;
  }

  .bottom-nav button span {
    font-size: 22px;
  }

  /* Home: train overview and parent choices sit side by side. */
  #homeScreen {
    display: grid;
    grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
    gap: 14px;
    align-items: stretch;
  }

  #homeScreen .hero-card {
    height: 100%;
    min-height: 0;
    padding: 20px;
    border-radius: 27px;
    display: grid;
    grid-template-rows: auto minmax(180px, 1fr) auto;
  }

  #homeScreen .hero-copy h1 {
    font-size: clamp(28px, 3.2vw, 38px);
  }

  #homeScreen .hero-copy p {
    margin-top: 7px;
    font-size: 13px;
  }

  #homeScreen .train-scene {
    height: auto;
    min-height: 205px;
    margin: 0;
  }

  #homeScreen .train {
    right: 0;
    scale: 0.82;
    transform-origin: right bottom;
  }

  #homeScreen .monster-one {
    left: 1%;
  }

  #homeScreen .monster-two {
    right: 32%;
  }

  #homeScreen .journey-status {
    margin-top: 5px;
    padding: 11px 12px;
  }

  #homeScreen .setup-panel {
    height: 100%;
    min-height: 0;
    margin-top: 0;
    padding: 17px 18px;
    border-radius: 27px;
  }

  #homeScreen .section-heading {
    margin-bottom: 10px;
  }

  #homeScreen .section-heading h2 {
    font-size: 22px;
  }

  #homeScreen .choice-group {
    margin-bottom: 10px;
  }

  #homeScreen .choice-group legend {
    margin-bottom: 5px;
    font-size: 12px;
  }

  #homeScreen .segmented button {
    min-height: 40px;
    padding: 7px;
  }

  #homeScreen .mode-grid {
    gap: 7px;
  }

  #homeScreen .mode-option {
    min-height: 61px;
    padding: 7px 9px;
    grid-template-columns: 31px 1fr;
    gap: 6px;
  }

  #homeScreen .mode-option > span {
    font-size: 22px;
  }

  #homeScreen .mode-option strong {
    font-size: 12px;
  }

  #homeScreen .mode-option small {
    font-size: 9px;
  }

  #homeScreen .switch-row {
    gap: 7px;
    margin-bottom: 9px;
  }

  #homeScreen .switch-control {
    padding: 8px;
    grid-template-columns: 37px 1fr;
    gap: 6px;
  }

  #homeScreen .switch-track {
    transform: scale(0.86);
    transform-origin: left center;
  }

  #homeScreen .switch-control strong {
    font-size: 11px;
  }

  #homeScreen .switch-control small {
    font-size: 9px;
  }

  #homeScreen .pool-summary {
    min-height: 39px;
    margin-bottom: 8px;
    padding: 7px 10px;
    font-size: 11px;
  }

  #homeScreen .kid-action {
    min-height: 62px;
    padding: 7px 10px;
  }

  #homeScreen .kid-action-icon {
    flex-basis: 46px;
    width: 46px;
    height: 46px;
    font-size: 24px;
  }

  #homeScreen .kid-action strong {
    font-size: 14px;
  }

  #homeScreen .kid-action small {
    font-size: 10px;
  }

  #homeScreen .fine-print {
    display: none;
  }

  /* Badge album: two compact rows of badges. */
  #albumScreen {
    display: grid;
    align-content: start;
    gap: 9px;
  }

  #albumScreen > .page-heading,
  #albumScreen > .album-progress-panel,
  #albumScreen > .route-panel {
    margin: 0;
  }

  #albumScreen .page-heading h1 {
    font-size: 31px;
  }

  #albumScreen .album-progress-panel,
  #albumScreen .route-panel {
    padding: 11px 17px;
  }

  #albumScreen .badge-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 7px;
    margin: 0;
  }

  #albumScreen .badge-slot {
    min-height: 111px;
    padding: 7px 4px;
    border-radius: 17px;
  }

  #albumScreen .mini-medallion {
    width: 56px;
    height: 56px;
  }

  #albumScreen .badge-slot strong {
    font-size: 9px;
  }

  /* Parent dashboard: settings/sync and history/details use two columns. */
  #parentScreen {
    display: grid;
    grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
    grid-template-rows: auto auto auto;
    gap: 10px 13px;
    align-items: start;
  }

  #parentScreen > .page-heading {
    grid-column: 1 / -1;
    margin: 0 2px;
  }

  #parentScreen > .settings-panel {
    grid-column: 1;
    grid-row: 2;
    height: 100%;
    margin: 0;
  }

  #parentScreen > .family-sync-panel {
    grid-column: 2;
    grid-row: 2;
    height: 100%;
    margin: 0;
  }

  #parentScreen > .parent-history-panel,
  #parentScreen > .parent-rewards-panel {
    grid-column: 1;
    grid-row: 3;
    margin: 0;
  }

  #parentScreen > .parent-details-panel {
    grid-column: 2;
    grid-row: 3;
    margin: 0;
  }

  #parentScreen:has(.parent-rewards-panel:not([hidden])) .parent-history-panel {
    display: none;
  }

  #parentScreen .page-heading h1 {
    font-size: 32px;
  }

  #parentScreen .panel {
    padding: 14px 16px;
    border-radius: 22px;
  }

  #parentScreen .settings-panel {
    gap: 5px;
  }

  #parentScreen .field-label {
    margin: 1px 0 3px;
    font-size: 11px;
  }

  #parentScreen .text-input {
    min-height: 40px;
    padding: 7px 10px;
    font-size: 13px;
  }

  #parentScreen .primary-button,
  #parentScreen .secondary-button {
    min-height: 40px;
    padding: 7px 11px;
  }

  #parentScreen .parent-tool-button {
    display: grid;
    width: 104px;
    min-height: 80px;
    margin: 0;
    padding: 8px 7px;
    place-items: center;
    gap: 4px;
    border-radius: 19px;
    text-align: center;
    box-shadow: 0 5px 12px rgba(70, 53, 159, .12);
  }

  #parentScreen .parent-tool-button > span { font-size: 26px; line-height: 1; }
  #parentScreen .parent-tool-button > strong { font-size: 11px; line-height: 1.2; }
  #parentScreen .settings-panel .parent-tool-button { justify-self: start; }
  #parentScreen .sync-actions { display: flex; align-items: flex-start; gap: 9px; }
  #parentScreen .sync-actions .text-button { align-self: center; }
  #parentScreen .details-panel .button-row { align-items: flex-start; }

  #parentScreen .voice-test-box {
    gap: 4px;
    margin-top: 1px;
    padding-top: 7px;
  }

  #parentScreen .voice-test-status {
    font-size: 10px;
    line-height: 1.35;
  }

  #parentScreen .section-heading.compact {
    margin-bottom: 7px;
  }

  #parentScreen .section-heading h2 {
    font-size: 22px;
  }

  #parentScreen .family-sync-panel > p {
    margin-bottom: 7px;
    font-size: 11px;
    line-height: 1.4;
  }

  #parentScreen .sync-cloud-icon {
    font-size: 27px;
  }

  #parentScreen .sync-code-box {
    padding: 9px 11px;
    font-size: 14px;
  }

  #parentScreen .sync-status {
    margin: 6px 0;
    padding: 6px 8px;
    font-size: 11px;
  }

  #parentScreen .sync-actions {
    gap: 6px;
  }

  #parentScreen .sync-actions button {
    min-height: 39px;
  }

  #parentScreen .sync-note {
    margin-top: 6px;
    font-size: 9px;
    line-height: 1.35;
  }

  #parentScreen .history-item {
    padding: 6px 0;
  }

  #parentScreen .history-item strong {
    font-size: 11px;
  }

  #parentScreen .history-item small {
    font-size: 9px;
  }

  #parentScreen .parent-badge {
    min-height: 25px;
    padding: 4px 7px;
    font-size: 9px;
  }

  #parentScreen .details-panel {
    padding: 12px 16px;
  }
}

@media (max-height: 720px) {
  .completion-stage {
    min-height: 0;
    margin-top: 6px;
    padding-top: 8px;
  }

  .completion-stage h1 {
    margin: 7px 0;
    font-size: 26px;
  }

  .completion-stage .lead {
    margin: 5px auto;
    font-size: 14px;
  }

  .crystal-track-board {
    width: min(100%, 620px);
    height: auto;
    margin-top: 10px;
  }

  .core-zone {
    width: 126px;
    height: 96px;
  }

  .crystal-button {
    width: 74px;
    height: 74px;
  }

  .crystal-button span {
    font-size: 40px;
  }

  .app-dialog {
    padding: 16px;
  }

  .app-dialog h2 {
    margin: 4px 0;
  }

  .app-dialog p {
    margin: 7px 0;
  }

  .rescue-options {
    gap: 7px;
  }

  .rescue-options button {
    min-height: 88px;
    padding: 8px;
  }
}

/* Keep the same large visual hit areas on compact phones. */
@media (max-width: 380px) {
  .game-topline {
    grid-template-columns: 64px 1fr 64px;
  }

  .game-topline .kid-icon-button {
    width: 64px;
    height: 64px;
    font-size: 31px;
  }

  .step-arrow {
    width: 46px;
    height: 50px;
    font-size: 37px;
  }

  .game-actions,
  .completion-action-grid { gap: 10px; }

  .game-actions .kid-action,
  .completion-action-grid .kid-action { min-height: 136px; }

  .game-actions .kid-action .kid-action-icon,
  .completion-action-grid .kid-action .kid-action-icon {
    width: 66px;
    height: 66px;
    flex-basis: 66px;
    font-size: 38px;
  }
}

@media (max-width: 620px) {
  .setup-layout {
    grid-template-columns: 1fr;
  }

  #homeScreen .setup-draw-panel #prepareDrawButton {
    min-height: 205px;
  }
}

/* Parent tools are compact picture cards, not narrow text strips. */
#parentScreen .parent-tool-button {
  display: grid;
  width: 104px;
  min-height: 80px;
  margin: 0;
  padding: 8px 7px;
  place-items: center;
  gap: 4px;
  border-radius: 19px;
  text-align: center;
  box-shadow: 0 5px 12px rgba(70, 53, 159, .12);
}

#parentScreen .parent-tool-button > span { font-size: 26px; line-height: 1; }
#parentScreen .parent-tool-button > strong { font-size: 11px; line-height: 1.2; }
#parentScreen .settings-panel .parent-tool-button { justify-self: start; }
#parentScreen .sync-actions { display: flex; align-items: flex-start; gap: 9px; }
#parentScreen .sync-actions .text-button { align-self: center; }
#parentScreen .details-panel .button-row { align-items: flex-start; }

#parentScreen .settings-panel { display: grid; gap: 10px; }
#parentScreen .settings-action-row { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 10px; align-items: stretch; padding-top: 3px; border-top: 1px solid var(--line); }
#parentScreen .settings-action-row .parent-tool-button { width: 92px; min-height: 78px; align-self: center; }
#parentScreen .voice-download-card { display: grid; grid-template-columns: 104px minmax(0, 1fr); align-items: center; gap: 10px; min-width: 0; padding: 7px 10px; border: 1px solid #d9d5ff; border-radius: 18px; background: linear-gradient(135deg, #f7f6ff, #edf9ff); }
#parentScreen .voice-download-card .parent-tool-button { width: 96px; min-height: 70px; }
#parentScreen .voice-test-status { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }

/* Keep the optional audio pack close to the start of the journey, without turning it into a large parent control. */
.home-voice-download {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  min-height: 25px;
  margin: 0 4px 6px;
}

.home-voice-download .text-button {
  padding: 3px 4px;
  color: var(--muted);
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.home-voice-download .voice-test-status {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

#parentScreen .settings-panel { gap: 8px; }
#parentScreen .nickname-field-row {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 410px;
}

#parentScreen .nickname-field-row .text-input {
  width: min(300px, calc(100% - 58px));
  flex: 1 1 0;
}

#parentScreen .parent-save-icon {
  display: grid;
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  min-height: 46px;
  margin: 0;
  padding: 0;
  place-items: center;
  border-radius: 14px;
}

#parentScreen .parent-save-icon span { font-size: 22px; line-height: 1; }

/* Badge album: book shelf first, then forge progress, then the three crystals. */
#albumScreen .album-book-tabs {
  gap: 17px;
  margin: 2px 0 18px;
  padding: 6px 8px 16px;
}

#albumScreen .album-book-tab,
#albumScreen .album-book-placeholder {
  width: clamp(142px, 28vw, 184px);
  min-width: clamp(142px, 28vw, 184px);
  padding: 16px 10px 13px 24px;
  border: 2px solid rgba(92, 78, 195, .25);
  border-radius: 9px 21px 21px 9px;
  background: linear-gradient(145deg, #f7f5ff, #e9e5ff);
  transition: transform 180ms ease, filter 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

#albumScreen .album-book-cover-visual {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 116px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,.78);
  border-radius: 5px 14px 14px 5px;
  background: linear-gradient(135deg, #1e1764, #6652df 52%, #8ee4ff);
  box-shadow: inset 0 0 0 1px rgba(22, 12, 88, .14), 0 7px 15px rgba(48, 37, 128, .22);
}

#albumScreen .album-book-cover-image {
  position: absolute;
  inset: 0;
  background-position: center;
  background-size: cover;
  filter: saturate(1.15) contrast(1.05);
  transform: scale(1.05);
}

#albumScreen .album-book-cover-image::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(150deg, rgba(25,16,91,.22), transparent 48%, rgba(9,7,45,.44));
  content: "";
}

#albumScreen .album-book-cover-montage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: radial-gradient(circle at 23% 20%, #bdfaff 0 5%, transparent 6%), radial-gradient(circle at 76% 23%, #ffe991 0 5%, transparent 6%), linear-gradient(135deg, #291977, #724df0 52%, #28b9e9);
}

#albumScreen .album-cover-badge {
  position: absolute;
  width: 73%;
  height: 73%;
  object-fit: contain;
  filter: drop-shadow(0 7px 7px rgba(14, 5, 70, .48));
}

#albumScreen .album-cover-badge:nth-child(1) { top: -12%; left: -18%; transform: rotate(-15deg); }
#albumScreen .album-cover-badge:nth-child(2) { right: -18%; bottom: -15%; transform: rotate(13deg); }
#albumScreen .album-cover-badge:nth-child(3) { top: 24%; left: 18%; width: 68%; height: 68%; transform: rotate(2deg); }

#albumScreen .album-book-number {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  display: block;
  color: #fffdf1;
  background: transparent;
  box-shadow: none;
  font-size: clamp(48px, 10vw, 72px);
  font-weight: 950;
  letter-spacing: -.1em;
  line-height: 1;
  text-shadow: 0 4px 0 rgba(27, 14, 99, .52), 0 7px 16px rgba(13, 6, 66, .55), 0 0 2px #fff;
  transform: translate(-52%, -50%);
}

#albumScreen .album-book-copy { position: relative; z-index: 2; }
#albumScreen .album-book-tab strong { color: var(--ink); font-size: 15px; }
#albumScreen .album-book-tab small { color: #626a8e; font-size: 11px; }

#albumScreen .album-book-tab:not(.is-selected) { filter: saturate(.72) brightness(.98); }
#albumScreen .album-book-tab:not(.is-selected):not(:disabled):hover { filter: saturate(.9) brightness(1.02); transform: translateY(-3px); }
#albumScreen .album-book-tab.is-selected {
  z-index: 1;
  border-color: #5840e4;
  background: linear-gradient(145deg, #fffdf2, #ccf4ff);
  box-shadow: 0 0 0 5px rgba(91,74,232,.18), inset 8px 0 rgba(255,255,255,.78), 0 16px 28px rgba(64, 45, 174, .28);
  filter: saturate(1.14) brightness(1.04);
  transform: translateY(-7px) scale(1.045);
}

#albumScreen .album-book-tab.is-selected .album-book-number {
  color: #fff4a7;
  text-shadow: 0 4px 0 rgba(105, 50, 142, .64), 0 7px 18px rgba(81, 44, 156, .58), 0 0 8px rgba(255,246,174,.86);
}

#albumScreen .album-book-placeholder .album-book-cover-visual { background: linear-gradient(135deg, #dee1ea, #b5bac9); }
#albumScreen .album-book-placeholder .album-book-number { color: #f4f5f8; text-shadow: 0 3px 0 rgba(93,99,119,.52), 0 6px 14px rgba(71,76,94,.32); }
#albumScreen .album-book-lock { position: absolute; top: 14px; right: 13px; font-size: 21px; filter: grayscale(1); }

#albumScreen .album-progress-panel {
  margin-top: 16px;
  border: 1px solid rgba(94, 187, 225, .28);
  background: linear-gradient(135deg, rgba(255,255,255,.98), rgba(227,248,255,.94));
}

#albumScreen .album-progress-panel .status-label { color: #3e5b82; }
#albumScreen .forge-panel { margin-top: 0; }

/* Two short progress cards: badges for the furnace, crystals for the next badge. */
#albumScreen .album-reward-progress {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 2px;
}

#albumScreen .album-reward-progress .forge-panel,
#albumScreen .album-reward-progress .album-progress-panel {
  min-height: 112px;
  margin: 0;
  padding: 15px 16px;
  border-radius: 22px;
}

#albumScreen .album-reward-progress .forge-panel {
  grid-template-columns: 52px minmax(0, 1fr) 72px;
  gap: 11px;
  align-items: center;
}

#albumScreen .album-reward-progress .forge-panel-icon {
  width: 52px;
  height: 52px;
  border-radius: 17px;
  font-size: 29px;
}

#albumScreen .album-reward-progress .forge-panel-copy h2 {
  font-size: 18px;
  line-height: 1.15;
}

#albumScreen .album-reward-progress .forge-panel-copy p,
#albumScreen .album-reward-progress .album-progress-panel p {
  margin: 3px 0 0;
  font-size: 12px;
  line-height: 1.3;
}

#albumScreen .compact-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

#albumScreen .compact-progress strong {
  flex: 0 0 auto;
  color: var(--purple-deep);
  font-size: 12px;
}

#albumScreen .compact-progress-track {
  display: block;
  flex: 1 1 auto;
  overflow: hidden;
  height: 8px;
  border-radius: 99px;
  background: rgba(105, 93, 193, .15);
}

#albumScreen .compact-progress-track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #6650e8, #7ce0ff);
  box-shadow: 0 0 9px rgba(103, 80, 232, .38);
  transition: width 400ms ease;
}

#albumScreen .album-reward-progress .album-progress-panel {
  display: grid;
  align-content: center;
  justify-content: stretch;
  gap: 0;
}

#albumScreen .crystal-progress { margin-top: 3px; }
#albumScreen .crystal-progress .energy-pips.large { margin: 0; }
#albumScreen .crystal-progress .energy-pip { width: 20px; height: 20px; }

#albumScreen .album-reward-progress .forge-open-button {
  grid-column: 3;
  grid-row: 1;
  display: grid;
  width: 72px;
  min-height: 72px;
  margin: 0;
  padding: 6px;
  place-items: center;
  gap: 1px;
  border-radius: 22px;
}

#albumScreen .album-reward-progress .forge-open-button .kid-action-icon { width: 34px; height: 34px; font-size: 22px; }
#albumScreen .album-reward-progress .forge-open-button .kid-action-copy { margin: 0; text-align: center; }
#albumScreen .album-reward-progress .forge-open-button .kid-action-copy strong { font-size: 12px; white-space: nowrap; }
#albumScreen .album-reward-progress .forge-open-button .kid-action-copy small { display: none; }

#albumScreen .album-reward-progress .forge-open-button.is-waiting {
  color: #4e4982;
  background: linear-gradient(145deg, #f6f4ff, #e8e4ff);
  box-shadow: 0 8px 18px rgba(69, 57, 145, 0.12);
}

@media (max-width: 560px) {
  #albumScreen .album-reward-progress { grid-template-columns: 1fr; }
}

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