:root {
  --p-pink: #f79ac2;
  --p-pink-dark: #e36ba3;
  --p-lav: #b39de6;
  --p-cream: #fff6fb;
  --p-panel: #ffffff;
  --p-gold: #ffd24c;
  --p-text: #5b4b63;
  --p-text-soft: #9a8aa2;
  --p-shadow: rgba(90, 60, 90, 0.14);
}

/* Reset and base font inherited from shared/variables.css */

body {
  background: var(--p-cream);
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--p-text);
}

/* ===== SCREENS ===== */
.screen {
  display: none;
  min-height: 100vh;
}
.screen.active {
  display: flex;
  flex-direction: column;
}

/* ===== WELCOME SCREEN ===== */
#welcome {
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #f7d9ee 0%, #efe1fb 50%, #d9ecff 100%);
  text-align: center;
  padding: 20px;
  gap: 20px;
}

.welcome-princess {
  font-size: 120px;
  will-change: transform;
  animation: princessBounce 2s ease-in-out infinite;
  filter: drop-shadow(0 8px 16px rgba(120, 70, 130, 0.2));
}

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

.welcome-title {
  font-size: 42px;
  font-weight: 900;
  color: var(--p-pink-dark);
  text-shadow: 2px 2px 0 #fff;
  letter-spacing: 4px;
}

.welcome-subtitle {
  font-size: 17px;
  color: var(--p-text);
  max-width: 340px;
  line-height: 1.5;
}

.welcome-features {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 460px;
}

.feature-tag {
  background: var(--p-panel);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 2px 8px var(--p-shadow);
}

.btn-start {
  background: linear-gradient(135deg, var(--p-pink), var(--p-lav));
  border: none;
  color: #fff;
  font-size: 28px;
  font-weight: 800;
  padding: 18px 56px;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(227, 107, 163, 0.4);
  transition: transform 0.2s;
  margin-top: 8px;
  letter-spacing: 2px;
}

.btn-start:active {
  transform: scale(0.95);
}

/* ===== DRESSING SCREEN ===== */
#dressing {
  height: 100vh;
  overflow: hidden;
}

.dress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: linear-gradient(135deg, var(--p-pink), var(--p-lav));
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 10px var(--p-shadow);
  z-index: 10;
}

.dress-title {
  font-size: 18px;
  font-weight: 800;
  white-space: nowrap;
}

.dress-tools {
  display: flex;
  gap: 6px;
}

.tool-btn {
  min-height: 44px;
  min-width: 56px;
  padding: 6px 12px;
  border: none;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--p-pink-dark);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s;
}

.tool-btn.primary {
  background: var(--p-gold);
  color: #7a5600;
}

.tool-btn:active {
  transform: scale(0.94);
}

.dress-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== STAGE ===== */
.stage-wrap {
  height: 55vh;
  flex-shrink: 0;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage {
  position: relative;
  width: 100%;
  max-width: 360px;
  height: 100%;
  border-radius: 24px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5);
  background: linear-gradient(180deg, #efd9ff, #fbcfe8);
}

.stage::before,
.stage::after {
  position: absolute;
  pointer-events: none;
  z-index: 0;
}

.doll {
  position: relative;
  z-index: 1;
  width: min(72%, 300px);
  will-change: transform;
  animation: dollFloat 3.6s ease-in-out infinite;
}

.doll-svg {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 6px 10px rgba(90, 60, 90, 0.22));
}

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

.doll.bounce {
  animation: dollBounce 0.42s ease-out;
}

@keyframes dollBounce {
  0% {
    transform: scale(1, 1) translateY(0);
  }
  30% {
    transform: scale(1.07, 0.94) translateY(-10px);
  }
  60% {
    transform: scale(0.97, 1.03) translateY(0);
  }
  100% {
    transform: scale(1, 1) translateY(0);
  }
}

/* Blink: briefly squash the eyes group every few seconds. */
.doll-eyes {
  transform-box: fill-box;
  transform-origin: center;
  animation: dollBlink 4s ease-in-out infinite;
}

@keyframes dollBlink {
  0%,
  92%,
  100% {
    transform: scaleY(1);
  }
  96% {
    transform: scaleY(0.1);
  }
}

/* ===== STAGE BACKGROUNDS ===== */
.bg-castle {
  background: linear-gradient(180deg, #efd9ff 0%, #fbcfe8 100%);
}
.bg-castle::before {
  content: '🏰';
  bottom: 2%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 120px;
  opacity: 0.22;
}
.bg-castle::after {
  content: '✨';
  top: 8%;
  right: 12%;
  font-size: 40px;
  opacity: 0.5;
}

.bg-garden {
  background: linear-gradient(180deg, #d7f2df 0%, #fff6cf 100%);
}
.bg-garden::before {
  content: '🌷';
  bottom: 3%;
  left: 8%;
  font-size: 72px;
  opacity: 0.34;
}
.bg-garden::after {
  content: '🦋';
  top: 12%;
  right: 12%;
  font-size: 44px;
  opacity: 0.55;
}

.bg-ball {
  background: linear-gradient(180deg, #5b4a86 0%, #caa24d 100%);
}
.bg-ball::before {
  content: '✨';
  top: 10%;
  left: 12%;
  font-size: 52px;
  opacity: 0.65;
}
.bg-ball::after {
  content: '💫';
  bottom: 10%;
  right: 14%;
  font-size: 52px;
  opacity: 0.55;
}

.bg-rainbow {
  background: linear-gradient(180deg, #c4e8ff 0%, #eafaff 100%);
}
.bg-rainbow::before {
  content: '🌈';
  top: 5%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 110px;
  opacity: 0.4;
}
.bg-rainbow::after {
  content: '☁️';
  bottom: 12%;
  left: 10%;
  font-size: 56px;
  opacity: 0.7;
}

/* ===== WARDROBE ===== */
.wardrobe {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--p-cream);
  border-top: 2px solid #f2e2ee;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 8px;
  overflow-x: auto;
  background: var(--p-panel);
  flex-shrink: 0;
}

.tab {
  flex: 0 0 auto;
  min-height: 48px;
  padding: 6px 14px;
  border: none;
  border-radius: 14px;
  background: #f6eef4;
  color: var(--p-text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s;
}

.tab:active {
  transform: scale(0.95);
}

.tab.active {
  background: linear-gradient(135deg, var(--p-pink), var(--p-pink-dark));
  color: #fff;
  box-shadow: 0 3px 8px rgba(227, 107, 163, 0.35);
}

.tab-emoji {
  font-size: 22px;
}
.tab-label {
  font-size: 12px;
}

.tray {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 10px;
  align-content: start;
}

.cell {
  position: relative;
  min-height: 100px;
  border: 3px solid transparent;
  border-radius: 16px;
  background: var(--p-panel);
  box-shadow: var(--pcg-shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px;
  cursor: pointer;
  transition: transform 0.15s;
}

.cell:active {
  transform: scale(0.95);
}

.cell.selected {
  border-color: var(--p-pink-dark);
  background: #fff2f8;
  box-shadow: 0 0 0 2px rgba(247, 154, 194, 0.4);
}

.cell .thumb {
  width: 62px;
  height: 62px;
}

.cell-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--p-text);
  text-align: center;
  line-height: 1.15;
}

.check {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--p-pink-dark);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--pcg-shadow-sm);
}

.bg-swatch {
  width: 62px;
  height: 62px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}

.bg-emoji {
  font-size: 30px;
}

.none-mark {
  font-size: 34px;
  filter: grayscale(0.2);
}

/* ===== CELEBRATE OVERLAY ===== */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(60, 40, 70, 0.55);
  padding: 20px;
}

.overlay[hidden] {
  display: none;
}

.celebrate-inner {
  background: linear-gradient(180deg, #fff6fb, #ffe9f4);
  border-radius: 28px;
  padding: 24px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: var(--pcg-shadow-lg);
  animation: popIn 0.4s var(--pcg-ease-bounce);
}

@keyframes popIn {
  from {
    transform: scale(0.7);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.celebrate-doll {
  width: min(58vw, 240px);
  margin: 0 auto;
  border-radius: 20px;
  padding: 8px;
}

.celebrate-doll .doll-svg {
  width: 100%;
  height: auto;
}

.celebrate-praise {
  font-size: 24px;
  font-weight: 800;
  color: var(--p-pink-dark);
  margin: 14px 0 4px;
}

.celebrate-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 12px;
}

.btn-continue,
.btn-home {
  min-height: 52px;
  padding: 12px 28px;
  border: none;
  border-radius: 50px;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: transform 0.15s;
}

.btn-continue {
  background: linear-gradient(135deg, var(--p-pink), var(--p-pink-dark));
  color: #fff;
  box-shadow: 0 4px 12px rgba(227, 107, 163, 0.35);
}

.btn-home {
  background: #fff;
  color: var(--p-pink-dark);
  box-shadow: var(--pcg-shadow-sm);
}

.btn-continue:active,
.btn-home:active {
  transform: scale(0.95);
}

/* ===== CONFETTI ===== */
.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 250;
}

/* ===== SCROLLBARS ===== */
.tray::-webkit-scrollbar,
.tabs::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.tray::-webkit-scrollbar-thumb,
.tabs::-webkit-scrollbar-thumb {
  background: #e6cfe0;
  border-radius: 3px;
}

/* ===== WIDE / LANDSCAPE LAYOUT ===== */
@media (min-width: 768px) {
  .dress-main {
    flex-direction: row;
  }

  .stage-wrap {
    height: auto;
    flex: 1.1;
    padding: 20px;
  }

  .stage {
    max-width: 460px;
  }

  .wardrobe {
    flex: 1;
    max-width: 440px;
    border-top: none;
    border-left: 2px solid #f2e2ee;
  }
}

@media (max-width: 480px) {
  .welcome-title {
    font-size: 30px;
    letter-spacing: 2px;
  }
  .welcome-princess {
    font-size: 96px;
  }
  .btn-start {
    font-size: 22px;
    padding: 14px 40px;
  }
  .dress-title {
    font-size: 15px;
  }
  .tool-btn {
    padding: 6px 8px;
    font-size: 13px;
    min-width: 50px;
  }
}

body,
.screen {
  min-height: 100dvh;
}
#dressing {
  height: 100dvh;
}
.dress-header {
  flex-wrap: wrap;
  padding-top: max(8px, env(safe-area-inset-top));
  padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
}
.dress-main,
.wardrobe {
  min-height: 0;
  min-width: 0;
}
.wardrobe {
  padding-bottom: env(safe-area-inset-bottom);
}
.stage-wrap {
  height: 45dvh;
}
.doll {
  max-height: 100%;
  aspect-ratio: 320 / 520;
}
.doll svg {
  max-height: 100%;
}
.celebrate-inner {
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
}
@media (min-width: 768px), (orientation: landscape) {
  .dress-main {
    flex-direction: row;
  }
  .stage-wrap {
    height: auto;
    flex: 1;
    min-width: 0;
    padding: 8px;
  }
  .wardrobe {
    flex: 1;
    min-width: 0;
    max-width: 440px;
  }
}
