:root {
  --ink: #172052;
  --navy: #263578;
  --navy-dark: #17245f;
  --paper: #f4f7ff;
  --white: #ffffff;
  --red: #ff4f62;
  --yellow: #ffd43b;
  --blue: #4385ff;
  --green: #36c78d;
  --purple: #8e63ee;
  --orange: #ff963d;
  --muted: #68709a;
  --line: #dfe5f6;
  --shadow: 0 12px 28px rgba(39, 53, 120, 0.13);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
  -webkit-tap-highlight-color: transparent;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--navy);
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12px 12px, rgba(67, 133, 255, 0.08) 2px, transparent 2.5px) 0 0 / 24px 24px,
    var(--paper);
}

button {
  font: inherit;
}

button:focus-visible {
  outline: 4px solid rgba(67, 133, 255, 0.35);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

#app {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: calc(68px + env(safe-area-inset-top));
  padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  color: white;
  background: var(--navy);
  box-shadow: 0 5px 0 rgba(23, 36, 95, 0.2);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0;
  border: 0;
  color: white;
  background: transparent;
  font-size: 1.15rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  cursor: pointer;
}

.brand strong {
  color: var(--yellow);
  font-weight: 950;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 13px);
  gap: 3px;
  padding: 6px;
  border-radius: 10px;
  background: white;
  box-shadow: 0 4px 0 var(--navy-dark);
}

.brand-mark i {
  width: 13px;
  height: 13px;
  border-radius: 4px;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.1);
}

.brand-mark i:nth-child(1) { background: var(--red); }
.brand-mark i:nth-child(2) { background: var(--yellow); }
.brand-mark i:nth-child(3) { background: var(--green); }
.brand-mark i:nth-child(4) { background: var(--blue); }

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

.star-bank {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 40px;
  padding: 0 12px;
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  background: rgba(14, 26, 87, 0.3);
  font-variant-numeric: tabular-nums;
}

.star-bank span {
  color: var(--yellow);
  font-size: 1.2rem;
}

.icon-button,
.install-button {
  min-width: 42px;
  min-height: 42px;
  padding: 0 10px;
  border: 0;
  border-radius: 13px;
  color: var(--navy);
  background: white;
  box-shadow: 0 4px 0 var(--navy-dark);
  font-size: 1.1rem;
  font-weight: 900;
  cursor: pointer;
}

.icon-button:active,
.install-button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--navy-dark);
}

.install-button {
  padding-inline: 14px;
  font-size: 0.85rem;
}

main {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: 26px max(16px, env(safe-area-inset-right)) calc(36px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.home-screen {
  width: min(100%, 1040px);
  margin: 0 auto;
}

.welcome-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 2px 22px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 950;
  letter-spacing: 0.12em;
}

h1,
h2,
p {
  overflow-wrap: break-word;
}

h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.7rem, 7vw, 2.65rem);
  line-height: 1.04;
  letter-spacing: -0.045em;
}

.buddy {
  position: relative;
  flex: 0 0 auto;
  width: 74px;
  height: 64px;
  border: 4px solid var(--ink);
  border-radius: 20px;
  background: var(--yellow);
  box-shadow: inset 0 -9px 0 rgba(255, 150, 61, 0.26), 0 7px 0 rgba(23, 32, 82, 0.14);
  transform: rotate(3deg);
}

.buddy::before,
.buddy::after {
  position: absolute;
  top: -12px;
  width: 20px;
  height: 15px;
  content: "";
  border: 4px solid var(--ink);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: var(--yellow);
}

.buddy::before { left: 9px; }
.buddy::after { right: 9px; }

.buddy-eye {
  position: absolute;
  top: 20px;
  width: 8px;
  height: 11px;
  border-radius: 50%;
  background: var(--ink);
}

.buddy-eye.left { left: 20px; }
.buddy-eye.right { right: 20px; }

.buddy-smile {
  position: absolute;
  bottom: 12px;
  left: 50%;
  width: 24px;
  height: 12px;
  border-bottom: 4px solid var(--ink);
  border-radius: 0 0 18px 18px;
  transform: translateX(-50%);
}

.game-grid {
  display: grid;
  gap: 16px;
}

.game-card {
  position: relative;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  width: 100%;
  min-height: 146px;
  padding: 20px;
  overflow: hidden;
  text-align: left;
  border: 3px solid transparent;
  border-radius: 26px;
  background: var(--white);
  box-shadow: var(--shadow), 0 7px 0 var(--line);
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.game-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 34px rgba(39, 53, 120, 0.16), 0 9px 0 var(--line);
}

.game-card:active {
  transform: translateY(5px);
  box-shadow: 0 7px 18px rgba(39, 53, 120, 0.13), 0 2px 0 var(--line);
}

.game-card::after {
  position: absolute;
  right: -30px;
  bottom: -58px;
  width: 150px;
  height: 150px;
  content: "";
  border-radius: 50%;
  background: currentColor;
  opacity: 0.055;
}

.card-pop { color: var(--red); border-color: rgba(255, 79, 98, 0.15); }
.card-stack { color: var(--blue); border-color: rgba(67, 133, 255, 0.15); }
.card-stickers { color: var(--purple); border-color: rgba(142, 99, 238, 0.15); }
.card-maze { color: var(--orange); border-color: rgba(255, 150, 61, 0.18); }
.card-copy { color: var(--green); border-color: rgba(54, 199, 141, 0.18); }
.card-memory { color: var(--navy); border-color: rgba(38, 53, 120, 0.18); }
.card-race { color: var(--red); border-color: rgba(255, 79, 98, 0.2); }

.difficulty-tag {
  position: absolute;
  z-index: 2;
  top: 10px;
  right: 12px;
  padding: 5px 8px;
  border-radius: 9px;
  color: currentColor;
  background: rgba(255, 255, 255, 0.92);
  font-size: 0.65rem;
  font-weight: 950;
  letter-spacing: 0.06em;
}

.card-number {
  position: absolute;
  top: 10px;
  left: 12px;
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: currentColor;
  font-size: 0.75rem;
  font-weight: 950;
}

.card-art {
  display: grid;
  width: 92px;
  height: 92px;
  place-items: center;
  border-radius: 23px;
}

.pop-art {
  grid-template-columns: repeat(3, 21px);
  grid-template-rows: repeat(3, 21px);
  gap: 5px;
  background: #fff0f2;
}

.pop-art i {
  width: 21px;
  height: 21px;
  border-radius: 6px;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.12), 0 2px 0 rgba(0, 0, 0, 0.08);
}

.red { background: var(--red); }
.yellow { background: var(--yellow); }
.blue { background: var(--blue); }
.green { background: var(--green); }

.stack-art {
  position: relative;
  display: block;
  background: #edf4ff;
}

.stack-art i {
  position: absolute;
  left: 50%;
  height: 13px;
  border-radius: 4px;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12);
  transform: translateX(-50%);
}

.stack-art i:nth-child(1) { bottom: 12px; width: 67px; background: var(--navy); }
.stack-art i:nth-child(2) { bottom: 26px; width: 59px; margin-left: -2px; background: var(--blue); }
.stack-art i:nth-child(3) { bottom: 40px; width: 51px; margin-left: 3px; background: var(--green); }
.stack-art i:nth-child(4) { bottom: 54px; width: 44px; margin-left: -1px; background: var(--yellow); }
.stack-art i:nth-child(5) { bottom: 68px; width: 36px; margin-left: 4px; background: var(--red); }

.sticker-art {
  grid-template-columns: repeat(2, 37px);
  gap: 5px;
  background: #f4efff;
}

.sticker-art i {
  display: grid;
  width: 37px;
  height: 37px;
  place-items: center;
  border: 2px solid white;
  border-radius: 12px;
  background: white;
  box-shadow: 0 4px 0 #d7caf7;
  font-size: 1.35rem;
  font-style: normal;
}

.sticker-art i:nth-child(3) {
  grid-column: 1 / -1;
  justify-self: center;
}

.maze-art {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 4px;
  padding: 10px;
  background: #fff2e5;
}

.maze-art b {
  border-radius: 5px;
  background: var(--orange);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12);
}

.maze-art b:nth-of-type(1) { grid-area: 1 / 2; }
.maze-art b:nth-of-type(2) { grid-area: 2 / 2; }
.maze-art b:nth-of-type(3) { grid-area: 2 / 3; }
.maze-art i,
.maze-art em {
  display: grid;
  place-items: center;
  font-size: 1.45rem;
  font-style: normal;
}
.maze-art i { grid-area: 3 / 1; }
.maze-art em { grid-area: 1 / 3; }

.copy-art {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 18px);
  grid-template-rows: repeat(2, 18px);
  gap: 5px;
  align-content: center;
  background: #eafbf4;
}

.copy-art i,
.copy-art b {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12);
}
.copy-art i:nth-of-type(1), .copy-art b:nth-of-type(1) { background: var(--blue); }
.copy-art i:nth-of-type(2), .copy-art b:nth-of-type(2) { background: var(--red); }
.copy-art i:nth-of-type(3), .copy-art b:nth-of-type(3) { background: var(--yellow); }
.copy-art i:nth-of-type(4), .copy-art b:nth-of-type(4) { background: var(--green); }
.copy-art span {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--navy);
  font-size: 0.9rem;
  transform: translate(-50%, -50%);
}

.memory-art {
  grid-template-columns: repeat(2, 31px);
  grid-template-rows: repeat(2, 31px);
  gap: 6px;
  background: #eef0fb;
}
.memory-art i {
  width: 31px;
  height: 31px;
  border-radius: 9px;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.15), 0 3px 0 rgba(23, 32, 82, 0.12);
}
.memory-art i:nth-child(1) { background: var(--red); }
.memory-art i:nth-child(2) { background: var(--blue); }
.memory-art i:nth-child(3) { background: var(--yellow); }
.memory-art i:nth-child(4) { background: var(--green); animation: light-pulse 1.2s ease infinite; }

.race-art {
  position: relative;
  width: 96px;
  height: 82px;
  overflow: hidden;
  border-radius: 18px;
  background: #414b64;
  border: 5px solid #a4df7f;
}
.race-art::before,
.race-art::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  background: repeating-linear-gradient(to bottom, white 0 10px, transparent 10px 18px);
}
.race-art::before { left: 31px; }
.race-art::after { right: 31px; }
.race-art i,
.race-art em { position: absolute; z-index: 2; font-style: normal; }
.race-art i { left: 8px; bottom: 5px; font-size: 30px; }
.race-art em { right: 7px; top: 5px; font-size: 22px; }

@keyframes light-pulse {
  50% { transform: scale(1.14); filter: brightness(1.22); }
}

.card-copy {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.card-copy strong {
  color: var(--ink);
  font-size: clamp(1.2rem, 3vw, 1.5rem);
  font-weight: 950;
  letter-spacing: -0.025em;
}

.card-copy small {
  color: var(--muted);
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.35;
}

.play-chip {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 48px;
  padding: 0 15px;
  border-radius: 15px;
  color: white;
  background: currentColor;
  font-size: 0.83rem;
  font-weight: 950;
  letter-spacing: 0.06em;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.16);
}

.play-chip b {
  font-size: 1.5rem;
  line-height: 0;
}

.safe-note {
  margin: 28px 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 0.88rem;
  font-weight: 700;
}

.safe-note span { color: var(--red); }

.game-screen {
  width: min(100%, 720px);
  margin: 0 auto;
}

.game-toolbar {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.back-button {
  width: 54px;
  height: 54px;
  padding: 0 0 5px;
  border: 0;
  border-radius: 17px;
  color: var(--ink);
  background: white;
  box-shadow: 0 5px 0 var(--line);
  font-size: 2.2rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.back-button:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--line);
}

.game-heading {
  min-width: 0;
}

.game-heading span,
.score-pill span {
  display: block;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 950;
  letter-spacing: 0.1em;
}

.game-heading h2 {
  margin: 2px 0 0;
  overflow: hidden;
  color: var(--ink);
  font-size: clamp(1.1rem, 5vw, 1.6rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-pill {
  min-width: 78px;
  padding: 8px 12px;
  border: 2px solid var(--line);
  border-radius: 16px;
  text-align: center;
  background: white;
}

.score-pill strong {
  display: block;
  margin-top: 2px;
  color: var(--navy);
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
}

.game-container {
  position: relative;
  min-height: 510px;
  padding: clamp(14px, 4vw, 24px);
  overflow: hidden;
  border: 3px solid var(--line);
  border-radius: 28px;
  background: white;
  box-shadow: var(--shadow), 0 7px 0 var(--line);
}

.instruction {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 10px 13px;
  border-radius: 15px;
  color: var(--ink);
  background: #eef3ff;
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.25;
}

.instruction strong {
  color: var(--blue);
  white-space: nowrap;
}

.pop-progress {
  height: 13px;
  margin: 0 0 17px;
  overflow: hidden;
  border: 2px solid #dce4f7;
  border-radius: 99px;
  background: #edf1fa;
}

.pop-progress i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--blue));
  transition: width 260ms ease;
}

.block-board {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: clamp(4px, 1.3vw, 8px);
  width: min(100%, 480px);
  margin: 0 auto;
  touch-action: manipulation;
}

.block-cell {
  position: relative;
  aspect-ratio: 1 / 0.83;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: var(--cell-color);
  box-shadow: inset 0 -7px 0 var(--cell-shade), 0 3px 0 rgba(23, 32, 82, 0.13);
  cursor: pointer;
  transition: transform 120ms ease;
}

.block-cell::before {
  position: absolute;
  top: 8%;
  left: 17%;
  width: 66%;
  height: 23%;
  content: "";
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.28);
}

.block-cell:hover { transform: translateY(-2px); }
.block-cell:active { transform: scale(0.9); }
.block-cell.popping { animation: pop-out 230ms ease forwards; }
.block-cell.wiggle { animation: wiggle 280ms ease; }

@keyframes pop-out {
  45% { transform: scale(1.16) rotate(5deg); }
  100% { transform: scale(0) rotate(-12deg); opacity: 0; }
}

@keyframes wiggle {
  25% { transform: translateX(-4px) rotate(-2deg); }
  50% { transform: translateX(4px) rotate(2deg); }
  75% { transform: translateX(-2px); }
}

.mini-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}

.soft-button,
.drop-button,
.dialog-button {
  min-height: 50px;
  padding: 0 18px;
  border: 0;
  border-radius: 16px;
  color: var(--navy);
  background: #eef3ff;
  box-shadow: 0 5px 0 #d4dff7;
  font-size: 0.92rem;
  font-weight: 950;
  cursor: pointer;
}

.soft-button:active,
.drop-button:active,
.dialog-button:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #cbd7f0;
}

.stack-wrap {
  display: grid;
  gap: 14px;
}

.stack-canvas-wrap {
  position: relative;
  overflow: hidden;
  border: 3px solid #cedbfb;
  border-radius: 22px;
  background:
    radial-gradient(circle at 22px 22px, rgba(255, 255, 255, 0.7) 2px, transparent 2.5px) 0 0 / 44px 44px,
    linear-gradient(#d8e8ff 0 66%, #c9f0d5 66% 100%);
}

#stack-canvas {
  display: block;
  width: 100%;
  height: 420px;
  touch-action: manipulation;
}

.stack-goal {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 13px;
  color: var(--navy);
  background: rgba(255, 255, 255, 0.86);
  font-size: 0.78rem;
  font-weight: 950;
  backdrop-filter: blur(5px);
}

.drop-button {
  width: 100%;
  min-height: 62px;
  color: white;
  background: var(--blue);
  box-shadow: 0 7px 0 #2865d4;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
}

.drop-button:active {
  transform: translateY(4px);
  box-shadow: 0 3px 0 #2865d4;
}

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

.robot-stage {
  position: relative;
  display: grid;
  height: 118px;
  place-items: center;
  overflow: hidden;
  border: 2px solid #e2daf8;
  border-radius: 20px;
  background:
    radial-gradient(circle at 15px 15px, rgba(142, 99, 238, 0.10) 2px, transparent 2.5px) 0 0 / 30px 30px,
    #f8f5ff;
}

.robot {
  position: relative;
  width: 112px;
  height: 105px;
}

.robot-part {
  position: absolute;
  border: 3px solid var(--ink);
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.13), 0 4px 0 rgba(23, 32, 82, 0.15);
  transition: transform 420ms cubic-bezier(0.2, 0.9, 0.3, 1.3), opacity 360ms ease;
}

.robot-part.gone {
  opacity: 0;
  transform: translate(var(--fly-x, 50px), 75px) rotate(38deg) scale(0.45);
}

.robot-antenna { top: 0; left: 51px; width: 12px; height: 20px; border-radius: 6px; background: var(--red); }
.robot-head { top: 15px; left: 28px; width: 58px; height: 35px; border-radius: 10px; background: var(--yellow); }
.robot-head::before,
.robot-head::after {
  position: absolute;
  top: 9px;
  width: 7px;
  height: 9px;
  content: "";
  border-radius: 50%;
  background: var(--ink);
}
.robot-head::before { left: 13px; }
.robot-head::after { right: 13px; }
.robot-eye-left { top: 25px; left: 39px; width: 10px; height: 10px; border-radius: 50%; background: white; }
.robot-eye-right { top: 25px; right: 39px; width: 10px; height: 10px; border-radius: 50%; background: white; }
.robot-body { top: 51px; left: 32px; width: 50px; height: 35px; border-radius: 7px; background: var(--blue); }
.robot-badge { z-index: 2; top: 60px; left: 50px; width: 14px; height: 14px; border-width: 2px; border-radius: 50%; background: var(--orange); }
.robot-arm-left { top: 53px; left: 8px; width: 23px; height: 17px; border-radius: 6px; background: var(--green); transform: rotate(-8deg); }
.robot-arm-right { top: 53px; right: 8px; width: 23px; height: 17px; border-radius: 6px; background: var(--green); transform: rotate(8deg); }
.robot-leg-left { top: 84px; left: 34px; width: 19px; height: 19px; border-radius: 5px; background: var(--purple); }
.robot-leg-right { top: 84px; right: 34px; width: 19px; height: 19px; border-radius: 5px; background: var(--purple); }

.tray-wrap {
  display: grid;
  gap: 5px;
}

.tray-label {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0.05em;
}

.sticker-tray {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
  padding: 7px;
  border: 3px solid #dcd4f3;
  border-radius: 17px;
  background: #ebe5fa;
  box-shadow: inset 0 4px 0 rgba(83, 57, 145, 0.08);
}

.tray-slot {
  display: grid;
  aspect-ratio: 1;
  place-items: center;
  border: 2px dashed #c6bae7;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.48);
  font-size: clamp(1.15rem, 6vw, 1.65rem);
}

.tray-slot.filled {
  border-style: solid;
  border-color: white;
  background: white;
  box-shadow: 0 3px 0 #c6bae7;
  animation: tray-in 180ms ease;
}

.tray-slot.matching { animation: match-bounce 360ms ease infinite alternate; }

@keyframes tray-in {
  from { transform: translateY(-12px) scale(0.75); opacity: 0; }
}

@keyframes match-bounce {
  to { transform: translateY(-5px) scale(1.08); background: #fff8c7; }
}

.sticker-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(5px, 1.5vw, 9px);
}

.sticker-tile {
  display: grid;
  aspect-ratio: 0.86;
  min-width: 0;
  padding: 0;
  place-items: center;
  border: 3px solid white;
  border-radius: 13px;
  color: var(--ink);
  background: var(--tile-bg, #f5f2ff);
  box-shadow: 0 5px 0 var(--tile-shadow, #d7caf7), 0 7px 12px rgba(37, 32, 86, 0.08);
  font-size: clamp(1.35rem, 7vw, 2rem);
  cursor: pointer;
  transition: transform 130ms ease, opacity 180ms ease;
}

.sticker-tile:hover { transform: translateY(-2px) rotate(-1deg); }
.sticker-tile:active { transform: translateY(3px) scale(0.93); box-shadow: 0 2px 0 var(--tile-shadow); }
.sticker-tile.picked { pointer-events: none; opacity: 0; transform: translateY(18px) scale(0.5); }

/* Jogo 4: caminho dos blocos */
.challenge-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.level-dots {
  display: flex;
  gap: 6px;
}

.level-dots i {
  width: 12px;
  height: 12px;
  border: 2px solid #ccd5ec;
  border-radius: 50%;
  background: white;
}
.level-dots i.done { border-color: var(--green); background: var(--green); }
.level-dots i.current { border-color: var(--blue); background: var(--blue); box-shadow: 0 0 0 4px rgba(67, 133, 255, 0.14); }

.maze-board {
  display: grid;
  grid-template-columns: repeat(var(--maze-size), minmax(0, 1fr));
  gap: clamp(2px, 0.8vw, 5px);
  width: min(100%, 470px);
  margin: 0 auto;
  padding: 7px;
  border: 3px solid #cfd9f1;
  border-radius: 20px;
  background: #e5ebf8;
  touch-action: none;
}

.maze-cell {
  position: relative;
  display: grid;
  aspect-ratio: 1;
  min-width: 0;
  place-items: center;
  border-radius: clamp(4px, 1.6vw, 9px);
  font-size: clamp(0.9rem, 5vw, 1.75rem);
}
.maze-cell.open { background: white; box-shadow: inset 0 -4px 0 #e1e6f2; }
.maze-cell.wall { background: var(--navy); box-shadow: inset 0 -6px 0 var(--navy-dark); }
.maze-cell.start { background: #dff8ec; }
.maze-cell.goal { background: #fff1cf; }
.maze-player { position: absolute; z-index: 2; filter: drop-shadow(0 3px 0 rgba(23, 32, 82, 0.18)); animation: car-in 160ms ease; }
.maze-star { color: var(--yellow); text-shadow: 0 2px 0 #d2a317; }

@keyframes car-in { from { transform: scale(0.65); } }

.direction-pad {
  display: grid;
  grid-template-columns: repeat(3, 62px);
  grid-template-rows: repeat(2, 56px);
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
}
.direction-button {
  border: 0;
  border-radius: 16px;
  color: white;
  background: var(--blue);
  box-shadow: 0 6px 0 #2865d4;
  font-size: 1.6rem;
  font-weight: 950;
  cursor: pointer;
}
.direction-button:active { transform: translateY(4px); box-shadow: 0 2px 0 #2865d4; }
.direction-up { grid-area: 1 / 2; }
.direction-left { grid-area: 2 / 1; }
.direction-down { grid-area: 2 / 2; }
.direction-right { grid-area: 2 / 3; }

/* Jogo 5: copiar a construção */
.copy-workbench {
  display: grid;
  gap: 16px;
}
.copy-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 13px;
  align-items: start;
}
.copy-panel {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 10px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: #f8faff;
}
.copy-panel strong {
  color: var(--muted);
  text-align: center;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
}
.copy-board {
  display: grid;
  grid-template-columns: repeat(var(--copy-size), minmax(0, 1fr));
  gap: clamp(4px, 1.5vw, 8px);
}
.copy-cell {
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  border: 2px solid rgba(23, 32, 82, 0.08);
  border-radius: clamp(7px, 2vw, 12px);
  background: var(--copy-color, #e9edf7);
  box-shadow: inset 0 -6px 0 rgba(23, 32, 82, 0.11), 0 3px 0 rgba(23, 32, 82, 0.1);
}
button.copy-cell { cursor: pointer; }
button.copy-cell:active { transform: scale(0.9); }
.copy-cell.wrong { animation: wiggle 280ms ease; }
.color-palette {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 10px;
  border-radius: 17px;
  background: #eef3ff;
}
.color-choice {
  width: 52px;
  height: 52px;
  padding: 0;
  border: 4px solid white;
  border-radius: 15px;
  background: var(--choice-color);
  box-shadow: 0 5px 0 var(--choice-shadow), 0 7px 12px rgba(23, 32, 82, 0.1);
  cursor: pointer;
}
.color-choice.selected { outline: 4px solid var(--ink); outline-offset: 2px; transform: translateY(-3px); }
.check-copy {
  width: 100%;
  min-height: 56px;
  border: 0;
  border-radius: 17px;
  color: white;
  background: var(--green);
  box-shadow: 0 6px 0 #20a970;
  font-weight: 950;
  cursor: pointer;
}
.check-copy:active { transform: translateY(4px); box-shadow: 0 2px 0 #20a970; }

/* Jogo 6: sequência de luzes */
.memory-game {
  display: grid;
  gap: 16px;
  justify-items: center;
}
.memory-status {
  width: 100%;
  padding: 11px 14px;
  border-radius: 15px;
  color: var(--ink);
  text-align: center;
  background: #eef3ff;
  font-weight: 850;
}
.memory-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
  width: min(100%, 390px);
  padding: 16px;
  border: 4px solid var(--navy);
  border-radius: 30px;
  background: #1a255f;
  box-shadow: 0 9px 0 #0f194b;
}
.memory-pad {
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  border: 5px solid rgba(255, 255, 255, 0.25);
  border-radius: 24px;
  background: var(--pad-color);
  box-shadow: inset 0 -13px 0 rgba(0, 0, 0, 0.18), 0 6px 0 rgba(0, 0, 0, 0.18);
  cursor: pointer;
  transition: filter 100ms ease, transform 100ms ease;
}
.memory-pad:disabled { cursor: default; opacity: 0.78; }
.memory-pad.active {
  filter: brightness(1.5) saturate(1.2);
  transform: scale(0.94);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.08), 0 0 28px var(--pad-color);
}
.memory-start {
  width: min(100%, 390px);
  min-height: 58px;
  border: 0;
  border-radius: 17px;
  color: white;
  background: var(--purple);
  box-shadow: 0 6px 0 #7045c4;
  font-weight: 950;
  cursor: pointer;
}
.memory-start:active { transform: translateY(4px); box-shadow: 0 2px 0 #7045c4; }

.race-wrap {
  position: relative;
  width: min(100%, 480px);
  margin: 0 auto;
}
.race-wrap canvas {
  display: block;
  width: 100%;
  height: 470px;
  border: 5px solid white;
  border-radius: 24px;
  box-shadow: 0 8px 0 #dfe5f1;
  touch-action: none;
}
.race-wrap .memory-start {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
}
.race-wrap .memory-start:active { transform: translate(-50%, calc(-50% + 4px)); }
.race-controls {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin-top: 18px;
}
.race-controls .direction-button { position: static; width: 82px; height: 62px; font-size: 2rem; }

.round-cover {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: grid;
  padding: 24px;
  place-items: center;
  background: rgba(23, 32, 82, 0.54);
  backdrop-filter: blur(6px);
}

.round-card {
  width: min(100%, 330px);
  padding: 27px 22px 24px;
  border: 4px solid white;
  border-radius: 26px;
  text-align: center;
  background: white;
  box-shadow: 0 12px 0 rgba(23, 32, 82, 0.24), 0 24px 60px rgba(0, 0, 0, 0.2);
  animation: dialog-in 280ms cubic-bezier(0.2, 1.4, 0.4, 1);
}

@keyframes dialog-in {
  from { transform: scale(0.68) rotate(-4deg); opacity: 0; }
}

.round-emoji {
  display: block;
  margin-bottom: 8px;
  font-size: 3.2rem;
}

.round-card h3 {
  margin: 0 0 7px;
  color: var(--ink);
  font-size: 1.75rem;
  line-height: 1.05;
}

.round-card p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.4;
}

.dialog-button {
  width: 100%;
  color: white;
  background: var(--blue);
  box-shadow: 0 6px 0 #2865d4;
}

.toast {
  position: fixed;
  z-index: 60;
  right: 18px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 18px;
  width: fit-content;
  max-width: calc(100% - 36px);
  min-height: 48px;
  margin: auto;
  padding: 12px 18px;
  border: 3px solid white;
  border-radius: 16px;
  color: white;
  background: var(--navy);
  box-shadow: 0 8px 22px rgba(23, 32, 82, 0.3);
  font-size: 0.92rem;
  font-weight: 850;
  opacity: 0;
  pointer-events: none;
  transform: translateY(24px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

.confetti {
  position: absolute;
  top: -30px;
  width: 12px;
  height: 20px;
  border-radius: 4px;
  animation: confetti-fall var(--fall-time) linear forwards;
}

@keyframes confetti-fall {
  to { transform: translate(var(--drift), 110vh) rotate(780deg); }
}

@media (min-width: 850px) {
  main { padding-top: 38px; }
  .game-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
  .game-card {
    grid-template-columns: 1fr;
    grid-template-rows: 112px auto auto;
    align-items: start;
    min-height: 374px;
    padding: 26px;
    text-align: center;
  }
  .card-art { width: 112px; height: 112px; justify-self: center; }
  .play-chip { justify-self: center; margin-top: auto; }
  .card-copy strong { font-size: 1.35rem; }
  .card-copy small { min-height: 44px; }
  .safe-note { margin-top: 34px; }
}

@media (max-width: 560px) {
  main { padding-top: 20px; }
  .topbar { min-height: calc(62px + env(safe-area-inset-top)); }
  .brand { gap: 8px; font-size: 1.02rem; }
  .brand-mark { grid-template-columns: repeat(2, 11px); }
  .brand-mark i { width: 11px; height: 11px; }
  .star-bank { height: 38px; padding: 0 10px; }
  .icon-button { min-width: 40px; min-height: 40px; }
  .welcome-row { margin-bottom: 17px; }
  .buddy { width: 62px; height: 55px; border-radius: 17px; }
  .buddy-eye { top: 16px; }
  .buddy-eye.left { left: 16px; }
  .buddy-eye.right { right: 16px; }
  .buddy-smile { bottom: 9px; }
  .game-card {
    grid-template-columns: 76px minmax(0, 1fr) 42px;
    gap: 12px;
    min-height: 122px;
    padding: 16px 12px 16px 16px;
    border-radius: 22px;
  }
  .difficulty-tag { top: 7px; right: 9px; font-size: 0.55rem; }
  .card-art { width: 76px; height: 76px; border-radius: 19px; transform: scale(0.88); }
  .play-chip { width: 42px; min-height: 46px; padding: 0; justify-content: center; }
  .play-chip { font-size: 0; }
  .play-chip b { font-size: 1.75rem; }
  .card-copy strong { font-size: 1.05rem; }
  .card-copy small { font-size: 0.86rem; }
  .game-toolbar { grid-template-columns: 50px minmax(0, 1fr) auto; gap: 9px; }
  .back-button { width: 50px; height: 50px; }
  .score-pill { min-width: 70px; padding-inline: 9px; }
  .game-container { min-height: 500px; padding: 13px; border-radius: 23px; }
  .instruction { font-size: 0.84rem; }
  #stack-canvas { height: 400px; }
  .copy-pair { gap: 8px; }
  .copy-panel { padding: 7px; }
  .color-choice { width: 46px; height: 46px; }
}

@media (max-width: 380px) {
  .brand > span:last-child { display: none; }
  .welcome-row .buddy { display: none; }
  .game-card { grid-template-columns: 70px minmax(0, 1fr) 38px; gap: 8px; }
  .card-art { margin-left: -5px; transform: scale(0.78); }
  .card-copy small { font-size: 0.78rem; }
  .play-chip { width: 38px; }
  .game-heading span { display: none; }
  .game-heading h2 { font-size: 1.02rem; }
  .score-pill span { font-size: 0.56rem; }
  .score-pill strong { font-size: 1.1rem; }
  .sticker-board { gap: 4px; }
  .sticker-tile { border-width: 2px; border-radius: 10px; }
}

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