:root {
  color-scheme: light;
  --bg: #fff8ec;
  --bg-soft: #eaf8ff;
  --ink: #293241;
  --muted: #637083;
  --line: #f0dfc3;
  --panel: #ffffff;
  --blue: #4aa8ff;
  --green: #64c96b;
  --yellow: #ffd166;
  --pink: #f78fb3;
  --orange: #ff9f43;
  --purple: #9b6dff;
  --red: #ff6b6b;
  --shadow: 0 16px 36px rgba(54, 42, 24, 0.14);
  --radius: 24px;
  font-family: ui-rounded, "SF Pro Rounded", "Comic Sans MS", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  color: var(--ink);
  background:
    linear-gradient(132deg, rgba(255, 209, 102, 0.34) 0 18%, transparent 18% 100%),
    linear-gradient(232deg, rgba(247, 143, 179, 0.28) 0 20%, transparent 20% 100%),
    linear-gradient(180deg, #eaf8ff 0%, var(--bg) 48%, #fff 100%);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.92) 0 20px, transparent 21px),
    radial-gradient(circle at 84% 16%, rgba(255, 255, 255, 0.72) 0 15px, transparent 16px),
    radial-gradient(circle at 78% 74%, rgba(123, 223, 242, 0.22) 0 34px, transparent 35px),
    radial-gradient(circle at 10% 78%, rgba(255, 209, 102, 0.24) 0 26px, transparent 27px);
  animation: background-drift 13s ease-in-out infinite alternate;
}

button {
  font: inherit;
}

button:active {
  transform: translateY(2px) scale(0.99);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(22px, env(safe-area-inset-bottom));
}

.topbar {
  display: grid;
  grid-template-columns: 54px 1fr 54px;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.topbar h1,
.kicker,
.round-title,
.task-title,
.reward h2,
.progress-card h2,
.progress-card p {
  margin: 0;
}

.topbar h1 {
  font-size: 1.55rem;
  line-height: 1.05;
  text-align: center;
}

.kicker {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
  text-align: center;
}

.icon-button {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 18px rgba(31, 41, 55, 0.12);
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.topbar .back-button.hidden {
  display: grid !important;
  visibility: hidden;
  pointer-events: none;
}

.screen {
  display: grid;
  gap: 16px;
}

.hero {
  position: relative;
  overflow: hidden;
  padding: 22px;
  border: 3px solid #fff;
  border-radius: 30px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.78)),
    conic-gradient(from 180deg at 50% 110%, #7bdff2, #b8f2e6, #fff3b0, #ffd6e7, #7bdff2);
  box-shadow: var(--shadow);
}

.hero::before {
  content: "";
  position: absolute;
  inset: auto -16% -36% -16%;
  height: 120px;
  border: 18px solid rgba(255, 209, 102, 0.38);
  border-top: 0;
  border-radius: 0 0 999px 999px;
  pointer-events: none;
}

.hero-emoji {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  gap: 12px;
  font-size: 3rem;
  margin-bottom: 8px;
}

.hero-emoji span {
  display: inline-block;
  filter: drop-shadow(0 10px 12px rgba(41, 50, 65, 0.14));
  animation: floaty 3.4s ease-in-out infinite;
}

.hero-emoji span:nth-child(2) {
  animation-delay: -1.1s;
}

.hero-emoji span:nth-child(3) {
  animation-delay: -2.1s;
}

.hero h2 {
  position: relative;
  z-index: 1;
  margin: 0 0 8px;
  font-size: 2rem;
  line-height: 1.05;
  text-align: center;
}

.hero p {
  position: relative;
  z-index: 1;
  margin: 0;
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
}

.hero-trail {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: min(210px, 72%);
  margin: 16px auto 0;
}

.hero-trail span {
  height: 8px;
  border-radius: 999px;
  transform-origin: left center;
  animation: trail-pulse 2.8s ease-in-out infinite;
}

.hero-trail span:nth-child(1) { background: var(--red); }
.hero-trail span:nth-child(2) { background: var(--yellow); animation-delay: 0.12s; }
.hero-trail span:nth-child(3) { background: var(--green); animation-delay: 0.24s; }
.hero-trail span:nth-child(4) { background: var(--blue); animation-delay: 0.36s; }

.menu-grid,
.answers,
.number-row,
.color-row,
.choice-grid {
  display: grid;
  gap: 12px;
}

.continue-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 3px solid rgba(255, 255, 255, 0.86);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.82)),
    linear-gradient(135deg, rgba(123, 223, 242, 0.26), rgba(255, 209, 102, 0.26));
  box-shadow: 0 10px 24px rgba(35, 45, 66, 0.1);
}

.continue-card span {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 950;
}

.menu-section {
  display: grid;
  gap: 12px;
}

.menu-section h2 {
  margin: 6px 4px -2px;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 950;
}

.menu-button,
.answer-card,
.big-button,
.reset-button {
  min-height: 74px;
  border: 0;
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 10px 24px rgba(35, 45, 66, 0.12);
  cursor: pointer;
  touch-action: manipulation;
}

.menu-button:hover,
.answer-card:hover,
.big-button:hover,
.reset-button:hover,
.icon-button:hover {
  filter: brightness(1.01);
}

.menu-button {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 58px 1fr;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  text-align: left;
}

.menu-button::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 8px;
  background: var(--button-accent, var(--yellow));
}

.menu-button::after {
  content: "";
  position: absolute;
  right: -24px;
  top: -20px;
  width: 92px;
  height: 92px;
  border: 14px solid color-mix(in srgb, var(--button-accent, var(--yellow)) 35%, transparent);
  border-radius: 30px;
  transform: rotate(18deg);
  pointer-events: none;
}

.menu-button:hover::after {
  transform: rotate(28deg) scale(1.05);
}

.menu-button:active .menu-emoji,
.answer-card:active,
.color-chip:active,
.number-choice:active {
  filter: saturate(1.08);
}

.menu-button[data-mode="noelia"] { --button-accent: var(--blue); }
.menu-button[data-mode="timeo"] { --button-accent: var(--green); }
.menu-button[data-mode="trace"] { --button-accent: var(--orange); }
.menu-button[data-mode="letterhunt"] { --button-accent: var(--pink); }
.menu-button[data-mode="shared"] { --button-accent: var(--yellow); }
.menu-button[data-mode="tictactoe"] { --button-accent: var(--red); }
.menu-button[data-mode="connect4"] { --button-accent: var(--purple); }
.menu-button[data-mode="memory"] { --button-accent: var(--green); }
.menu-button[data-mode="pattern"] { --button-accent: var(--blue); }

.menu-button strong {
  display: block;
  font-size: 1.25rem;
  line-height: 1.1;
}

.menu-button span:last-child {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.96rem;
  font-weight: 700;
}

.menu-emoji {
  position: relative;
  z-index: 1;
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 20px;
  font-size: 2rem;
  background: color-mix(in srgb, var(--button-accent, var(--yellow)) 24%, #ffffff);
  box-shadow: inset 0 -5px rgba(41, 50, 65, 0.07);
}

.menu-emoji::after {
  content: "";
  position: absolute;
  top: 8px;
  left: 12px;
  width: 16px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  transform: rotate(-20deg);
}

.menu-button > span:last-child {
  position: relative;
  z-index: 1;
}

.progress-card,
.game-card,
.reward,
.lock-card {
  padding: 18px;
  border: 3px solid rgba(255, 255, 255, 0.86);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.82));
  box-shadow: var(--shadow);
}

.lock-card {
  display: grid;
  min-height: 520px;
  align-content: center;
  gap: 14px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.82)),
    linear-gradient(135deg, rgba(123, 223, 242, 0.38), rgba(255, 209, 102, 0.28), rgba(247, 143, 179, 0.32));
}

.lock-card h2 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.05;
}

.lock-card p {
  margin: 0;
  color: var(--muted);
  font-size: 1.08rem;
  font-weight: 800;
}

.lock-emoji {
  font-size: 4.8rem;
  filter: drop-shadow(0 10px 14px rgba(41, 50, 65, 0.14));
}

.lock-form {
  display: grid;
  gap: 12px;
  margin-top: 6px;
}

.lock-input {
  width: 100%;
  min-height: 68px;
  border: 4px solid #ffffff;
  border-radius: 22px;
  background: #f8fbff;
  color: var(--ink);
  box-shadow: inset 0 -6px rgba(41, 50, 65, 0.05);
  font: inherit;
  font-size: 1.4rem;
  font-weight: 900;
  text-align: center;
  outline: none;
}

.lock-input:focus {
  border-color: #ffd166;
}

.progress-card h2 {
  font-size: 1.25rem;
}

.progress-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.progress-pill {
  display: grid;
  min-height: 76px;
  place-items: center;
  padding: 10px 6px;
  border-radius: 18px;
  background: #f8fbff;
  text-align: center;
}

.progress-pill strong {
  display: block;
  font-size: 1.35rem;
}

.progress-pill span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.reset-button {
  width: 100%;
  margin-top: 12px;
  min-height: 58px;
  background: #fff1f1;
  color: #a53232;
  font-weight: 900;
}

.round-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
}

.round-title {
  font-size: 1.5rem;
  line-height: 1.05;
}

.round-count {
  display: inline-grid;
  min-width: 72px;
  min-height: 44px;
  place-items: center;
  border-radius: 999px;
  background: #fff4cc;
  font-size: 1.05rem;
  font-weight: 900;
}

.stars {
  display: flex;
  gap: 5px;
  margin-top: 12px;
  font-size: 1.35rem;
}

.number-range {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.number-range button {
  min-height: 50px;
  border: 0;
  border-radius: 18px;
  background: #f8fbff;
  color: var(--ink);
  box-shadow: 0 7px 16px rgba(35, 45, 66, 0.1);
  font-size: 1.05rem;
  font-weight: 950;
}

.number-range button.selected {
  background: #293241;
  color: #ffffff;
}

.task-scene {
  position: relative;
  display: grid;
  place-items: center;
  gap: 12px;
  min-height: 180px;
  margin-top: 16px;
  padding: 16px;
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(239, 251, 255, 0.92), rgba(255, 255, 255, 0.95)),
    repeating-linear-gradient(45deg, rgba(123, 223, 242, 0.18) 0 12px, transparent 12px 24px);
}

.task-scene::before,
.task-scene::after {
  content: "✦";
  position: absolute;
  color: rgba(255, 209, 102, 0.85);
  font-size: 1.35rem;
  text-shadow: 0 3px 8px rgba(255, 159, 67, 0.2);
  animation: twinkle 2.6s ease-in-out infinite;
}

.task-scene::before {
  top: 18px;
  left: 20px;
}

.task-scene::after {
  right: 24px;
  bottom: 20px;
  color: rgba(247, 143, 179, 0.8);
  animation-delay: -1.3s;
}

.task-title {
  font-size: 1.6rem;
  line-height: 1.15;
  text-align: center;
}

.feedback {
  min-height: 34px;
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 900;
  text-align: center;
}

.answer-card {
  position: relative;
  overflow: hidden;
  display: grid;
  min-height: 92px;
  place-items: center;
  padding: 14px;
  font-size: 2.25rem;
  font-weight: 950;
}

.answer-card small {
  display: block;
  margin-top: 6px;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 900;
}

.monster {
  position: relative;
  display: grid;
  width: 148px;
  height: 138px;
  place-items: center;
  border: 5px solid #2f4858;
  border-radius: 44% 44% 50% 50%;
  background: linear-gradient(180deg, #8de969, #48bd77);
  box-shadow: inset 0 -12px rgba(0, 0, 0, 0.08);
  animation: monster-breathe 2.8s ease-in-out infinite;
}

.monster::before,
.monster::after {
  content: "";
  position: absolute;
  top: 38px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #293241;
}

.monster::before {
  left: 42px;
}

.monster::after {
  right: 42px;
}

.monster-mouth {
  width: 62px;
  height: 30px;
  margin-top: 42px;
  border-radius: 0 0 999px 999px;
  background: #293241;
  box-shadow: inset 0 8px rgba(255, 255, 255, 0.08);
}

.rocket-scene {
  position: relative;
  display: grid;
  width: 150px;
  height: 150px;
  place-items: center;
}

.rocket-scene::after {
  content: "";
  position: absolute;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 209, 102, 0.55) 0 18%, transparent 19%),
    conic-gradient(from 0deg, rgba(255, 107, 107, 0.3), rgba(74, 168, 255, 0.25), rgba(100, 201, 107, 0.22), rgba(255, 107, 107, 0.3));
  filter: blur(1px);
  animation: orbit 4s linear infinite;
}

.rocket {
  position: relative;
  z-index: 1;
  font-size: 4.7rem;
  transform: rotate(-28deg);
  filter: drop-shadow(0 13px 12px rgba(41, 50, 65, 0.14));
  animation: rocket-idle 2.2s ease-in-out infinite;
}

.stars-sky {
  position: absolute;
  inset: 0;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 6px;
  font-size: 1.7rem;
}

.train-track {
  position: relative;
  width: 100%;
  overflow: hidden;
  padding: 8px 0 4px;
}

.train-track::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 9px;
  height: 8px;
  border-radius: 999px;
  background: repeating-linear-gradient(90deg, rgba(41, 50, 65, 0.28) 0 18px, transparent 18px 28px);
}

.train {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: end;
  gap: 7px;
  min-height: 88px;
  transition: transform 0.45s ease;
}

.engine,
.wagon {
  display: grid;
  min-width: 64px;
  height: 58px;
  place-items: center;
  border: 4px solid #293241;
  border-radius: 18px 18px 8px 8px;
  background: #7bdff2;
  font-size: 1.8rem;
}

.engine {
  min-width: 82px;
  background: #ffd166;
}

.wagon {
  position: relative;
}

.wagon::before,
.wagon::after,
.engine::before,
.engine::after {
  content: "";
  position: absolute;
  bottom: -13px;
  width: 16px;
  height: 16px;
  border: 3px solid #293241;
  border-radius: 50%;
  background: #fff;
}

.wagon::before,
.engine::before {
  left: 10px;
}

.wagon::after,
.engine::after {
  right: 10px;
}

.engine,
.wagon {
  position: relative;
}

.selection-note {
  min-height: 28px;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 900;
  text-align: center;
}

.color-chip {
  position: relative;
  overflow: hidden;
  min-height: 66px;
  border: 4px solid #ffffff;
  border-radius: 22px;
  color: #293241;
  box-shadow: 0 8px 18px rgba(35, 45, 66, 0.12);
  font-size: 1.05rem;
  font-weight: 950;
}

.color-chip::after,
.answer-card::after,
.big-button::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 0 38%, rgba(255, 255, 255, 0.46) 46%, transparent 56% 100%);
  transform: translateX(-120%);
  transition: transform 0.42s ease;
  pointer-events: none;
}

.color-chip:hover::after,
.answer-card:hover::after,
.big-button:hover::after {
  transform: translateX(120%);
}

.color-chip.selected {
  outline: 5px solid #293241;
  transform: translateY(-3px);
}

.number-choice {
  position: relative;
  overflow: hidden;
  min-height: 70px;
  border: 0;
  border-radius: 22px;
  background: #fff4cc;
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(35, 45, 66, 0.12);
  font-size: 1.8rem;
  font-weight: 950;
}

.game-actions {
  display: grid;
  gap: 12px;
}

.board-scene {
  min-height: 260px;
}

.tic-board {
  display: grid;
  width: min(100%, 318px);
  aspect-ratio: 1;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.tic-cell {
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 22px;
  background: #fff4cc;
  box-shadow: inset 0 -6px rgba(41, 50, 65, 0.08);
  font-size: clamp(2.4rem, 16vw, 4rem);
  cursor: pointer;
}

.tic-cell:not(:empty) {
  animation: pop-in 0.24s ease-out;
}

.connect-board {
  display: grid;
  width: min(100%, 348px);
  aspect-ratio: 7 / 6;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  padding: 10px;
  border-radius: 24px;
  background: #4aa8ff;
  box-shadow: inset 0 -10px rgba(0, 0, 0, 0.12);
}

.connect-cell {
  display: grid;
  place-items: center;
  min-width: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.connect-cell span {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #eaf8ff;
  box-shadow: inset 0 4px rgba(41, 50, 65, 0.18);
}

.connect-cell.red span {
  background: #ff6b6b;
  animation: drop-in 0.28s ease-out;
}

.connect-cell.yellow span {
  background: #ffd166;
  animation: drop-in 0.28s ease-out;
}

.memory-board {
  perspective: 900px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.memory-card {
  position: relative;
  overflow: hidden;
  display: grid;
  min-height: 86px;
  place-items: center;
  border: 0;
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(255, 209, 102, 0.86), rgba(247, 143, 179, 0.82));
  color: var(--ink);
  box-shadow: 0 10px 22px rgba(35, 45, 66, 0.14), inset 0 -7px rgba(41, 50, 65, 0.08);
  font-size: 2.35rem;
  font-weight: 950;
  transform-style: preserve-3d;
  transition: transform 0.22s ease, background 0.22s ease;
}

.memory-card.open {
  background: #ffffff;
  transform: translateY(-2px) rotateY(8deg);
}

.pattern-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  min-height: 62px;
  margin-top: 16px;
  padding: 10px;
  border-radius: 22px;
  background: rgba(248, 251, 255, 0.9);
}

.pattern-input {
  margin-top: 10px;
  background: rgba(255, 244, 204, 0.62);
}

.pattern-dot {
  display: block;
  width: 44px;
  height: 44px;
  border: 4px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 7px 14px rgba(35, 45, 66, 0.12);
  animation: dot-pop 0.24s ease-out;
}

.pattern-dot:not(.filled) {
  box-shadow: inset 0 4px rgba(41, 50, 65, 0.08);
}

.letter-scene {
  min-height: 150px;
}

.letter-stack {
  position: relative;
  overflow: hidden;
  display: grid;
  min-width: 190px;
  min-height: 108px;
  place-items: center;
  border: 5px solid #ffffff;
  border-radius: 30px;
  background:
    linear-gradient(135deg, rgba(123, 223, 242, 0.35), rgba(255, 209, 102, 0.45)),
    #ffffff;
  box-shadow: inset 0 -10px rgba(41, 50, 65, 0.06);
  color: rgba(41, 50, 65, 0.78);
  font-size: 3.5rem;
  font-weight: 950;
}

.letter-stack::after {
  content: "";
  position: absolute;
  inset: -40% auto auto -35%;
  width: 72%;
  height: 180%;
  background: rgba(255, 255, 255, 0.32);
  transform: rotate(22deg);
  animation: slow-shine 4.5s ease-in-out infinite;
}

.letter-card {
  font-size: 3rem;
}

.trace-modes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.trace-mode {
  min-height: 54px;
  border: 0;
  border-radius: 18px;
  background: #f8fbff;
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 950;
  box-shadow: 0 7px 16px rgba(35, 45, 66, 0.1);
}

.trace-mode.selected {
  background: #293241;
  color: #ffffff;
}

.trace-tools {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.pen-row,
.guide-row {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.pen-button {
  width: 44px;
  height: 44px;
  border: 4px solid #ffffff;
  border-radius: 50%;
  background: var(--pen);
  box-shadow: 0 8px 16px rgba(35, 45, 66, 0.13);
}

.pen-button.selected {
  outline: 4px solid #293241;
}

.guide-button {
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: #f8fbff;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 950;
  box-shadow: 0 7px 14px rgba(35, 45, 66, 0.09);
}

.guide-button.selected {
  background: #ffd166;
}

.trace-pad {
  position: relative;
  width: 100%;
  min-height: 310px;
  margin-top: 14px;
  overflow: hidden;
  border: 5px solid #fff;
  border-radius: 28px;
  background:
    linear-gradient(90deg, rgba(41, 50, 65, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(41, 50, 65, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, #fffdf8, #fff8ec);
  background-size: 42px 42px;
  box-shadow: inset 0 -10px rgba(41, 50, 65, 0.05);
  animation: paper-glow 4.2s ease-in-out infinite alternate;
}

.trace-pad.guide-leicht .trace-ghost {
  color: rgba(74, 168, 255, 0.13);
}

.trace-pad.guide-frei .trace-ghost,
.trace-pad.guide-frei .trace-line {
  opacity: 0;
}

.trace-line {
  position: absolute;
  left: 9%;
  right: 9%;
  height: 4px;
  border-radius: 999px;
  background: rgba(41, 50, 65, 0.12);
  pointer-events: none;
}

.trace-line-top {
  top: 22%;
}

.trace-line-middle {
  top: 50%;
  background: repeating-linear-gradient(90deg, rgba(41, 50, 65, 0.13) 0 12px, transparent 12px 24px);
}

.trace-line-bottom {
  bottom: 22%;
}

.trace-ghost {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(74, 168, 255, 0.22);
  font-size: clamp(9rem, 48vw, 15rem);
  font-weight: 950;
  line-height: 1;
  pointer-events: none;
}

.trace-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.trace-meter {
  width: 100%;
  height: 18px;
  margin-top: 12px;
  overflow: hidden;
  border: 4px solid #ffffff;
  border-radius: 999px;
  background: #f8fbff;
  box-shadow: inset 0 3px rgba(41, 50, 65, 0.08);
}

.trace-meter-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #4aa8ff, #64c96b, #ffd166);
  background-size: 180% 100%;
  animation: meter-flow 1.4s linear infinite;
  transition: width 0.16s ease;
}

.trace-actions {
  grid-template-columns: 1fr;
}

.light-button {
  background: #fff4cc;
  color: var(--ink);
}

.big-button {
  position: relative;
  overflow: hidden;
  width: 100%;
  padding: 14px 18px;
  background: #293241;
  color: #ffffff;
  font-weight: 950;
}

.big-button.light-button {
  background: #fff4cc;
  color: var(--ink);
}

.reward {
  display: grid;
  min-height: 360px;
  align-content: center;
  justify-items: center;
  gap: 14px;
  text-align: center;
}

.reward-emoji {
  font-size: 5rem;
  filter: drop-shadow(0 14px 16px rgba(41, 50, 65, 0.14));
}

.reward h2 {
  font-size: 2rem;
  line-height: 1.05;
}

.reward p {
  margin: 0;
  color: var(--muted);
  font-size: 1.12rem;
  font-weight: 800;
}

.bounce {
  animation: bounce 0.55s ease;
}

.shake {
  animation: shake 0.4s ease;
}

.eat {
  animation: eat 0.55s ease;
}

.launch {
  animation: launch 0.8s ease;
}

.train-go {
  animation: train-go 0.85s ease;
}

.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  overflow: hidden;
}

.confetti span {
  position: absolute;
  top: -20px;
  width: 16px;
  height: 24px;
  border-radius: 5px;
  animation: fall 1.4s ease-out forwards;
}

.confetti span:nth-child(1) { left: 8%; background: var(--pink); animation-delay: 0s; }
.confetti span:nth-child(2) { left: 19%; background: var(--yellow); animation-delay: 0.08s; }
.confetti span:nth-child(3) { left: 30%; background: var(--blue); animation-delay: 0.02s; }
.confetti span:nth-child(4) { left: 42%; background: var(--green); animation-delay: 0.12s; }
.confetti span:nth-child(5) { left: 54%; background: var(--orange); animation-delay: 0.04s; }
.confetti span:nth-child(6) { left: 66%; background: var(--purple); animation-delay: 0.1s; }
.confetti span:nth-child(7) { left: 74%; background: var(--red); animation-delay: 0.03s; }
.confetti span:nth-child(8) { left: 82%; background: var(--yellow); animation-delay: 0.16s; }
.confetti span:nth-child(9) { left: 90%; background: var(--blue); animation-delay: 0.07s; }
.confetti span:nth-child(10) { left: 96%; background: var(--pink); animation-delay: 0.13s; }

.spark-burst {
  position: absolute;
  inset: 50% auto auto 50%;
  z-index: 4;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.spark-burst span {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.52);
  animation: sparkle-out 0.78s ease-out forwards;
}

.spark-burst span:nth-child(1) { --x: -56px; --y: -42px; background: var(--pink); }
.spark-burst span:nth-child(2) { --x: -18px; --y: -62px; background: var(--blue); animation-delay: 0.03s; }
.spark-burst span:nth-child(3) { --x: 38px; --y: -50px; background: var(--yellow); animation-delay: 0.05s; }
.spark-burst span:nth-child(4) { --x: 58px; --y: -8px; background: var(--green); animation-delay: 0.02s; }
.spark-burst span:nth-child(5) { --x: 42px; --y: 44px; background: var(--orange); animation-delay: 0.06s; }
.spark-burst span:nth-child(6) { --x: -10px; --y: 62px; background: var(--purple); animation-delay: 0.04s; }
.spark-burst span:nth-child(7) { --x: -54px; --y: 28px; background: var(--red); animation-delay: 0.01s; }
.spark-burst span:nth-child(8) { --x: 0; --y: -34px; background: #ffffff; animation-delay: 0.08s; }
.spark-burst span:nth-child(9) { --x: 28px; --y: 16px; background: var(--blue); animation-delay: 0.09s; }

@keyframes background-drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(0, -14px, 0) scale(1.02); }
}

@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-10px) rotate(4deg); }
}

@keyframes trail-pulse {
  0%, 100% { transform: scaleX(0.88); opacity: 0.78; }
  50% { transform: scaleX(1); opacity: 1; }
}

@keyframes twinkle {
  0%, 100% { transform: scale(0.8) rotate(0deg); opacity: 0.48; }
  50% { transform: scale(1.25) rotate(18deg); opacity: 1; }
}

@keyframes monster-breathe {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-4px) scale(1.025); }
}

@keyframes rocket-idle {
  0%, 100% { transform: translateY(0) rotate(-28deg); }
  50% { transform: translateY(-7px) rotate(-24deg); }
}

@keyframes orbit {
  from { transform: rotate(0deg) translateX(20px) rotate(0deg); }
  to { transform: rotate(360deg) translateX(20px) rotate(-360deg); }
}

@keyframes pop-in {
  from { transform: scale(0.72) rotate(-5deg); }
  to { transform: scale(1) rotate(0deg); }
}

@keyframes drop-in {
  from { transform: translateY(-22px) scale(0.86); }
  to { transform: translateY(0) scale(1); }
}

@keyframes dot-pop {
  from { transform: scale(0.68); opacity: 0.72; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes slow-shine {
  0%, 50% { transform: translateX(0) rotate(22deg); opacity: 0; }
  72% { opacity: 1; }
  100% { transform: translateX(260%) rotate(22deg); opacity: 0; }
}

@keyframes paper-glow {
  from { box-shadow: inset 0 -10px rgba(41, 50, 65, 0.05), 0 0 0 rgba(123, 223, 242, 0); }
  to { box-shadow: inset 0 -10px rgba(41, 50, 65, 0.05), 0 12px 32px rgba(123, 223, 242, 0.16); }
}

@keyframes meter-flow {
  from { background-position: 0% 50%; }
  to { background-position: 180% 50%; }
}

@keyframes sparkle-out {
  0% { transform: translate(-50%, -50%) scale(0.55); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(0); opacity: 0; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px) rotate(-2deg); }
  50% { transform: translateX(8px) rotate(2deg); }
  75% { transform: translateX(-5px) rotate(-1deg); }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  45% { transform: translateY(-16px) scale(1.04); }
}

@keyframes eat {
  0%, 100% { transform: scale(1); }
  35% { transform: scale(1.16) rotate(-4deg); }
  62% { transform: scale(0.96) rotate(3deg); }
}

@keyframes launch {
  0% { transform: translateY(0) rotate(-28deg); }
  55% { transform: translateY(-42px) rotate(-20deg) scale(1.08); }
  100% { transform: translateY(0) rotate(-28deg); }
}

@keyframes train-go {
  0% { transform: translateX(0); }
  45% { transform: translateX(32px); }
  70% { transform: translateX(20px); }
  100% { transform: translateX(0); }
}

@keyframes fall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(260deg); opacity: 0; }
}

@media (min-width: 560px) {
  .app-shell {
    padding-top: 24px;
  }

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

  .color-row,
  .number-row {
    grid-template-columns: repeat(3, 1fr);
  }

  .progress-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .trace-actions {
    grid-template-columns: repeat(4, 1fr);
  }
}

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