@font-face {
  font-family: Fredoka;
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
  src: url("fonts/fredoka-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: Fredoka;
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
  src: url("fonts/fredoka-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --ink: #5c3a45;
  --muted: #a56b7d;
  --pink: #ff6fa8;
  --line: #efd0de;
  --card: #fff;
  color-scheme: light;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  font-family: Fredoka, "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background-color: #fff3f8;
  background-image: radial-gradient(#ffd3e6 1.3px, transparent 1.3px);
  background-size: 22px 22px;
}

button, input { font: inherit; color: inherit; }

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

.shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h1 {
  margin: 0;
  font-size: clamp(1.45rem, 4vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}

.sub {
  margin: 3px 0 0;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.98rem;
}

.sound {
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  background: var(--card);
  box-shadow: 0 5px 0 var(--line);
  font-size: 26px;
}

.sound:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--line); }
.sound[aria-pressed="false"] { filter: grayscale(1); }

header > div { flex: 1; min-width: 0; }

.back {
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  background: var(--card);
  box-shadow: 0 5px 0 var(--line);
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

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

.play { display: contents; }

.picker {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  align-items: center;
}

.jobs,
.babies {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.job,
.baby {
  border: 3px solid #fff;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 6px 0 var(--line);
  font-weight: 700;
  line-height: 1.1;
}

.job {
  min-height: 108px;
  padding: 12px 6px 14px;
  font-size: 1.02rem;
  background: linear-gradient(180deg, var(--c) 0%, #fff 62%);
}

.baby {
  min-height: 188px;
  padding: 18px 8px;
  font-size: 1.2rem;
}

.job .emoji,
.baby .emoji { display: block; }

.job .emoji { font-size: 34px; margin-bottom: 4px; }
.baby .emoji { font-size: 68px; line-height: 1; margin-bottom: 8px; }

.job:active,
.baby:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--line); }

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 250px;
  border-radius: 32px;
  overflow: hidden;
  background: linear-gradient(180deg, #b7e7ff 0%, #e8f7ff 34%, #fff7fb 58%, #ffd5e6 100%);
  box-shadow: inset 0 -18px 0 rgba(255, 143, 184, 0.18), 0 10px 0 rgba(255, 255, 255, 0.7);
}

.window {
  position: absolute;
  top: 7%;
  left: 6%;
  width: 74px;
  height: 86px;
  background: #fff6c8;
  border: 7px solid #fff;
  border-radius: 16px;
  box-shadow: 0 8px 0 rgba(92, 58, 69, 0.06);
}

.window::before,
.window::after {
  content: "";
  position: absolute;
  background: #fff;
}

.window::before {
  left: 50%;
  top: 0;
  bottom: 0;
  width: 7px;
  margin-left: -3px;
}

.window::after {
  top: 50%;
  left: 0;
  right: 0;
  height: 7px;
  margin-top: -3px;
}

.sun {
  position: absolute;
  top: 9%;
  right: 8%;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #ffe08a;
  box-shadow: 0 0 0 10px rgba(255, 224, 138, 0.45);
}

.cloud {
  position: absolute;
  height: 22px;
  background: #fff;
  border-radius: 20px;
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: #fff;
  border-radius: 50%;
}

.cloud.c1 { width: 64px; top: 18%; right: 18%; }
.cloud.c1::before { width: 26px; height: 26px; top: -14px; left: 8px; }
.cloud.c1::after { width: 20px; height: 20px; top: -10px; left: 28px; }

.cloud.c2 { width: 48px; top: 28%; left: 22%; }
.cloud.c2::before { width: 18px; height: 18px; top: -10px; left: 8px; }

.rug {
  position: absolute;
  left: 50%;
  bottom: 8%;
  width: min(280px, 62%);
  height: 36px;
  transform: translateX(-50%);
  border-radius: 50%;
  background:
    radial-gradient(closest-side, transparent 58%, #fff 59% 68%, transparent 69%),
    radial-gradient(closest-side, #fff 0 28%, #ff8fb8 29% 62%, #7bdff2 63%);
}

.doll {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  --accent: #ff8fb8;
  --accent-2: #7ec8ff;
}

.hair-boy,
.only-girl,
.only-boy { display: none; }

#doll.boy .hair-girl { display: none; }
#doll.boy .hair-boy,
#doll.girl .only-girl,
#doll.boy .only-boy { display: inline; }

.sway {
  transform-box: view-box;
  transform-origin: 160px 430px;
  animation: sway 3.6s ease-in-out infinite;
}

.sway.dance { animation: dance 0.7s ease-in-out; }

@keyframes sway {
  0%, 100% { transform: rotate(-1.4deg); }
  50% { transform: rotate(1.4deg); }
}

@keyframes dance {
  0% { transform: rotate(0); }
  20% { transform: rotate(-7deg) translateY(4px); }
  45% { transform: rotate(7deg) translateY(-8px); }
  70% { transform: rotate(-4deg); }
  100% { transform: rotate(0); }
}

.lid {
  transform-box: fill-box;
  transform-origin: center;
  transform: scaleY(0);
  animation: blink 5.2s infinite;
}

@keyframes blink {
  0%, 90%, 100% { transform: scaleY(0); }
  94% { transform: scaleY(1); }
}

.wear:not(.on) { display: none; }
.wear.on {
  transform-box: fill-box;
  transform-origin: center;
  animation: pop 0.38s cubic-bezier(0.2, 1.4, 0.4, 1);
}

@keyframes pop {
  from { transform: scale(0.82); }
  to { transform: scale(1); }
}

#doll.has-outfit #diaper,
#doll.has-outfit #belly { display: none; }

.bubble {
  position: absolute;
  z-index: 2;
  top: 12px;
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 999px;
  box-shadow: 0 6px 0 rgba(92, 58, 69, 0.08);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  max-width: calc(100% - 24px);
  overflow: hidden;
  text-overflow: ellipsis;
}

.bubble.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  transition: 0.2s ease;
}

.fx {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  overflow: hidden;
}

.fx span {
  position: absolute;
  bottom: 30%;
  font-size: 22px;
  animation: floatup 1s ease-out forwards;
}

@keyframes floatup {
  from { transform: translateY(10px) scale(0.6); opacity: 1; }
  to { transform: translateY(-170px) scale(1.15); opacity: 0; }
}

.wardrobe {
  background: rgba(255, 255, 255, 0.8);
  border: 3px solid #fff;
  border-radius: 28px;
  padding: 10px;
  box-shadow: 0 10px 24px rgba(140, 60, 90, 0.08);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.tab {
  border: 3px solid transparent;
  background: #fff;
  border-radius: 16px;
  padding: 7px 2px 8px;
  box-shadow: 0 4px 0 var(--line);
  font-weight: 700;
  font-size: 13px;
  line-height: 1.1;
}

.tab .emoji { display: block; font-size: 22px; margin-bottom: 2px; }
.tab.on { background: #ffe4f1; border-color: var(--pink); }
.tab:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--line); }

.choices {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 10px 2px 8px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.choices::-webkit-scrollbar { height: 0; }

.choice {
  position: relative;
  flex: 0 0 96px;
  scroll-snap-align: start;
  border: 3px solid transparent;
  background: #fff;
  border-radius: 22px;
  min-height: 108px;
  padding: 8px 6px 10px;
  box-shadow: 0 6px 0 var(--line);
}

.choice:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--line); }

.choice.on {
  border-color: var(--pink);
  background: #fff5fa;
}

.choice.on::after {
  content: "✓";
  position: absolute;
  top: 4px;
  right: 7px;
  font-size: 14px;
  color: var(--pink);
}

.swatch {
  display: block;
  width: 100%;
  height: 48px;
  border-radius: 16px;
  background: var(--c);
  border: 2px solid rgba(92, 58, 69, 0.08);
  box-shadow: inset 0 -6px 0 rgba(255, 255, 255, 0.28);
}

.choice .name {
  display: block;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
}

.actions {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 8px;
}

.toy {
  border: 0;
  border-radius: 18px;
  padding: 14px 10px;
  background: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  box-shadow: 0 6px 0 var(--line);
}

.toy:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--line); }

.toy-y {
  background: #ffe08a;
  box-shadow: 0 6px 0 #e6c15a;
}

.toy-y:active { box-shadow: 0 2px 0 #e6c15a; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

button:focus-visible {
  outline: 3px solid #3d7eff;
  outline-offset: 2px;
}

@media (min-width: 960px) {
  body { display: block; padding: 12px 0; min-height: 100dvh; }

  .shell {
    width: min(1100px, calc(100% - 40px));
    margin: 0 auto;
    height: calc(100dvh - 24px);
    min-height: 0;
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 14px 18px;
    padding: 8px;
  }

  header { grid-column: 1 / -1; }
  .picker { grid-column: 1 / -1; }
  .jobs { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .stage { min-height: 0; height: 100%; }
  .wardrobe { display: flex; flex-direction: column; min-height: 0; }
  .choices {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    overflow: visible;
    flex: 1;
    align-content: start;
  }
  .choice { flex: none; width: auto; min-height: 112px; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .shell {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100dvh;
    min-height: 0;
  }
  header { grid-column: 1 / -1; }
  .picker { grid-column: 1 / -1; }
  .jobs { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .baby { min-height: 120px; padding: 10px 8px; font-size: 1rem; }
  .baby .emoji { font-size: 40px; margin-bottom: 4px; }
  .choices { display: flex; }
}

@media (prefers-reduced-motion: reduce) {
  .sway, .lid, .wear.on, .fx span { animation: none !important; }
  .bubble.show { transition: none; }
}
