:root {
  --bg: linear-gradient(180deg, #ffe3f1 0%, #ffdff0 30%, #dff6ff 100%);
  --card: rgba(255, 255, 255, 0.72);
  --card-strong: rgba(255, 255, 255, 0.9);
  --text: #4b3755;
  --soft-text: #6e5d7b;
  --pink: #ff86b7;
  --pink-strong: #f65fa1;
  --mint: #93ead4;
  --lavender: #bba8ff;
  --yellow: #ffd76a;
  --shadow: 0 14px 40px rgba(136, 96, 144, 0.18);
  --radius: 28px;
  --radius-small: 18px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

body {
  min-height: 100dvh;
}

button, a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

h1, h2, h3, p {
  margin: 0;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 26px);
}

.main-content {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.glass {
  background: var(--card);
  border: 1px solid rgba(255,255,255,0.62);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
}

.top-bar.compact {
  align-items: flex-start;
}

.eyebrow {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--soft-text);
  margin-bottom: 4px;
}

h1 {
  font-size: clamp(1.55rem, 2vw + 1rem, 2.45rem);
  line-height: 1.05;
}

h2 {
  font-size: clamp(1.2rem, 1.6vw + 0.9rem, 1.8rem);
}

p {
  color: var(--soft-text);
  line-height: 1.45;
}

.hud-row,
.stats-row,
.board-toolbar,
.hero-actions,
.section-heading,
.tips-grid,
.pet-switcher,
.page-tabs,
.palette,
.sticker-tray,
.control-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.wrap {
  justify-content: flex-end;
}

.counter-badge,
.small-pill {
  background: rgba(255,255,255,0.86);
  border: 1px solid rgba(255,255,255,0.7);
  border-radius: 999px;
  padding: 10px 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
  font-weight: 700;
}

.counter-badge.wide {
  justify-content: center;
}

.pill-button,
.cta-button,
.play-chip,
.page-tab,
.pet-button,
.choice-chip,
.sticker-choice {
  border-radius: 999px;
  padding: 11px 16px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  box-shadow: 0 8px 18px rgba(136, 96, 144, 0.14);
}

.pill-button,
.page-tab,
.pet-button,
.choice-chip,
.sticker-choice {
  background: rgba(255,255,255,0.88);
}

.cta-button,
.play-chip {
  background: linear-gradient(180deg, #ff9fca, #ff7db3);
  color: white;
  font-weight: 700;
}

button:active,
.game-card:active,
.page-tab:active,
.sticker-choice:active,
.choice-chip:active,
.pet-button:active {
  transform: translateY(1px) scale(0.98);
}

.hero-card,
.mini-hero,
.progress-card,
.tips-card,
.instructions-card,
.board-panel,
.canvas-panel,
.sticker-panel,
.dressup-stage-panel,
.controls-panel,
.gallery-panel {
  padding: 20px;
}

.island-hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  overflow: hidden;
}

.hero-visual {
  min-height: 170px;
  position: relative;
  background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.8), rgba(255,255,255,0)), linear-gradient(180deg, #c8f6ea, #ffecf6);
  border-radius: 26px;
}

.blob {
  position: absolute;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: rgba(255,255,255,0.82);
  display: grid;
  place-items: center;
  font-size: 2.5rem;
  box-shadow: 0 10px 24px rgba(143, 91, 129, 0.18);
}

.blob.one { top: 20px; left: 18px; }
.blob.two { right: 18px; top: 30px; }
.blob.three { left: 50%; bottom: 14px; transform: translateX(-50%); }

.floating {
  animation: bob 3.2s ease-in-out infinite;
}

.blob.two { animation-delay: 0.7s; }
.blob.three { animation-delay: 1.1s; }

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

.game-grid,
.progress-grid,
.coloring-layout,
.dressup-layout {
  display: grid;
  gap: 18px;
}

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

.game-card {
  padding: 22px;
  min-height: 220px;
  display: grid;
  align-content: start;
  gap: 12px;
  position: relative;
}

.game-card::after {
  content: "";
  position: absolute;
  inset: auto 20px 18px auto;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(255,255,255,0.4);
}

.game-card .play-chip {
  width: fit-content;
  margin-top: auto;
}

.game-card.pink { background: linear-gradient(180deg, rgba(255, 214, 231, 0.92), rgba(255,255,255,0.74)); }
.game-card.mint { background: linear-gradient(180deg, rgba(208, 255, 242, 0.92), rgba(255,255,255,0.74)); }
.game-card.lavender { background: linear-gradient(180deg, rgba(232, 226, 255, 0.92), rgba(255,255,255,0.74)); }

.game-icon {
  font-size: 2.4rem;
}

.progress-grid {
  grid-template-columns: 1.2fr 0.8fr;
}

.sticker-album {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.sticker-slot {
  min-height: 86px;
  border-radius: 22px;
  background: rgba(255,255,255,0.76);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 10px;
  font-size: 1.8rem;
  border: 2px dashed rgba(180, 163, 193, 0.32);
}

.sticker-slot.locked {
  color: #bdaec7;
  font-size: 1rem;
}

.reward-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.reward-list.small {
  margin-top: 8px;
}

.reward-item {
  background: rgba(255,255,255,0.8);
  border-radius: 18px;
  padding: 14px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.reward-item strong {
  display: block;
  margin-bottom: 4px;
}

.reward-tag {
  white-space: nowrap;
  font-size: 0.92rem;
  color: var(--pink-strong);
  font-weight: 800;
}

.tips-grid {
  justify-content: space-between;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(120px);
  opacity: 0;
  padding: 14px 18px;
  background: rgba(75, 55, 85, 0.92);
  color: white;
  border-radius: 999px;
  box-shadow: 0 16px 40px rgba(75, 55, 85, 0.35);
  transition: 0.25s ease;
  z-index: 40;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.memory-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.memory-card {
  aspect-ratio: 1 / 1;
  border-radius: 24px;
  background: linear-gradient(180deg, #fff9cf, #ffffff);
  display: grid;
  place-items: center;
  font-size: clamp(2rem, 2vw + 1.4rem, 3rem);
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 20px rgba(100, 81, 113, 0.14);
}

.memory-card .front,
.memory-card .back {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.memory-card .front {
  background: linear-gradient(180deg, #ffbddd, #ff8dbc);
  color: white;
  font-size: 2rem;
}

.memory-card .back {
  opacity: 0;
  transform: rotateY(90deg);
}

.memory-card.flipped .front,
.memory-card.matched .front {
  opacity: 0;
  transform: rotateY(90deg);
}

.memory-card.flipped .back,
.memory-card.matched .back {
  opacity: 1;
  transform: rotateY(0deg);
}

.memory-card.matched {
  background: linear-gradient(180deg, #dbfff3, #ffffff);
  outline: 3px solid rgba(147, 234, 212, 0.8);
}

.hidden {
  display: none !important;
}

.coloring-layout {
  grid-template-columns: 1.2fr 0.8fr;
  align-items: start;
}

.palette {
  margin-bottom: 14px;
}

.color-choice {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.92);
  box-shadow: 0 6px 14px rgba(75, 55, 85, 0.18);
}

.color-choice.selected {
  transform: scale(1.12);
  outline: 3px solid rgba(75, 55, 85, 0.16);
}

.coloring-canvas-wrap {
  position: relative;
  min-height: 420px;
  background: linear-gradient(180deg, rgba(255,255,255,0.85), rgba(255,255,255,0.65));
  border-radius: 26px;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.coloring-canvas-wrap svg {
  width: min(100%, 520px);
  height: auto;
}

.paint-target {
  cursor: pointer;
  transition: transform 0.15s ease;
}

.paint-target:active {
  transform: scale(0.98);
}

.sticker-panel {
  display: grid;
  gap: 14px;
}

.sticker-tray {
  align-items: stretch;
}

.sticker-choice {
  font-size: 1.4rem;
  min-width: 62px;
  text-align: center;
}

.sticker-choice.selected {
  background: linear-gradient(180deg, #ffe7f1, #ffffff);
  outline: 2px solid rgba(246, 95, 161, 0.22);
}

.placed-sticker {
  position: absolute;
  font-size: 2rem;
  transform: translate(-50%, -50%);
  pointer-events: none;
  filter: drop-shadow(0 6px 10px rgba(87, 59, 92, 0.14));
}

.page-tab.active,
.pet-button.active,
.choice-chip.active {
  background: linear-gradient(180deg, #ffe6f1, #ffffff);
  outline: 2px solid rgba(246, 95, 161, 0.22);
}

.dressup-layout {
  grid-template-columns: 1fr 1fr;
  align-items: start;
}

.dressup-stage {
  position: relative;
  min-height: 430px;
  border-radius: 30px;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.background-0 { background: linear-gradient(180deg, #d6fff4, #e5f4ff); }
.background-1 { background: linear-gradient(180deg, #ffe5f3, #fff4cb); }
.background-2 { background: linear-gradient(180deg, #e7dcff, #ffe6fa); }
.background-3 { background: linear-gradient(180deg, #fff6d6, #ddfffb); }

.pet-figure {
  font-size: clamp(6rem, 9vw, 8rem);
  z-index: 2;
}

.layer {
  position: absolute;
  display: grid;
  place-items: center;
  inset: 0;
  pointer-events: none;
  font-size: clamp(3rem, 4vw, 4rem);
}

.head-layer { top: -94px; z-index: 5; }
.face-layer { top: -12px; z-index: 4; }
.outfit-layer { top: 70px; z-index: 3; }
.handheld-layer { top: 128px; left: 82px; z-index: 6; }

.controls-panel {
  display: grid;
  gap: 18px;
}

.control-group {
  background: rgba(255,255,255,0.62);
  border-radius: 22px;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.control-group h3 {
  font-size: 1.05rem;
}

.choice-chip {
  min-width: 78px;
  text-align: center;
}

.look-gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.look-card {
  background: rgba(255,255,255,0.82);
  border-radius: 20px;
  padding: 14px;
  min-height: 128px;
  display: grid;
  gap: 10px;
}

.look-preview {
  min-height: 72px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 2.1rem;
  position: relative;
}

.look-preview span {
  position: absolute;
}

.look-preview .base { font-size: 2.8rem; }
.look-preview .head { top: 8px; }
.look-preview .face { top: 32px; }
.look-preview .outfit { top: 44px; }
.look-preview .handheld { top: 52px; left: 58%; }

.look-card small {
  color: var(--soft-text);
}

.back-link {
  white-space: nowrap;
}

.parent-button {
  background: linear-gradient(180deg, #fff4b7, #ffd975);
}

.chest-button {
  min-width: 180px;
}

.sparkle {
  position: fixed;
  font-size: 1.5rem;
  animation: sparkleUp 900ms ease forwards;
  pointer-events: none;
  z-index: 60;
}

@keyframes sparkleUp {
  from { opacity: 1; transform: translateY(0) scale(0.8); }
  to { opacity: 0; transform: translateY(-70px) scale(1.4); }
}

@media (max-width: 900px) {
  .island-hero,
  .progress-grid,
  .coloring-layout,
  .dressup-layout {
    grid-template-columns: 1fr;
  }

  .game-grid,
  .look-gallery {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 760px) {
  .top-bar,
  .top-bar.compact {
    flex-direction: column;
    align-items: flex-start;
  }

  .hud-row,
  .stats-row,
  .board-toolbar {
    width: 100%;
  }

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

  .memory-card {
    border-radius: 20px;
  }

  .coloring-canvas-wrap {
    min-height: 340px;
  }
}

@media (max-width: 520px) {
  .app-shell {
    padding-inline: 12px;
  }

  .hero-card,
  .mini-hero,
  .progress-card,
  .tips-card,
  .instructions-card,
  .board-panel,
  .canvas-panel,
  .sticker-panel,
  .dressup-stage-panel,
  .controls-panel,
  .gallery-panel {
    padding: 16px;
    border-radius: 24px;
  }

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

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

  .counter-badge,
  .small-pill,
  .pill-button,
  .cta-button,
  .page-tab,
  .pet-button,
  .choice-chip,
  .sticker-choice {
    padding: 10px 14px;
  }
}
