/* Dress Up test (lab only). One screen, no scrolling: the kid fills the stage, the picker sits in one dock row. */
main.activity.dress { display: flex; flex-direction: column; min-height: 0; width: 100%; align-self: stretch; box-sizing: border-box; }
.dress-stage {
  flex: 1 1 auto; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center;
  border-radius: 22px; overflow: hidden; overflow: clip; /* clip: the blurred fill's -20px edge must never let it scroll */
  background: radial-gradient(120% 90% at 50% 15%, #FFF6E8 0%, #F7E3D2 55%, #E9CDBB 100%);
}
:root[data-theme="dark"] .dress-stage { background: radial-gradient(120% 90% at 50% 15%, #3A3550 0%, #2A2640 60%, #1E1B30 100%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .dress-stage { background: radial-gradient(120% 90% at 50% 15%, #3A3550 0%, #2A2640 60%, #1E1B30 100%); } }
.dress-stage::after { /* a soft floor */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 16%;
  background: linear-gradient(to bottom, rgba(120, 80, 60, 0.10), rgba(120, 80, 60, 0.22));
}
.dress-kid { position: relative; z-index: 1; height: 96%; width: auto; max-width: 100%; transition: transform 180ms ease; }
/* Rooms. The room keeps its real shape: on wide screens it sits in the middle with a soft blurred copy at the
   sides; on tall screens (phones) it fills the height and trims its sides. The kid stands on the room's floor. */
.dress-stage { container-type: size; }
.room-box { position: relative; height: 100%; width: 100%; display: flex; align-items: center; justify-content: center; z-index: 1; }
main .dress-stage.has-room { background: #2A2433; }
.dress-stage.has-room::after { display: none; }
.dress-stage.has-room::before {
  content: ""; position: absolute; inset: -20px; background-image: var(--room); background-size: cover; background-position: center;
  filter: blur(18px) saturate(0.9) brightness(0.85);
}
.dress-stage.has-room .room-box {
  width: min(100cqw, 100cqh * 16 / 9); height: 100%; display: block; border-radius: 14px; overflow: hidden; overflow: clip;
}
/* The world = the room picture at its real shape; JS sizes it, zooms it and moves it to frame the family. */
.world { position: absolute; left: 0; top: 0; background-size: 100% 100%; background-repeat: no-repeat; transform-origin: 0 0; }
.world .dress-kid, .world .family-member {
  position: absolute; max-width: none; margin: 0; pointer-events: none;
  filter: drop-shadow(0 4px 4px rgba(40, 25, 15, 0.25)); transform-origin: 50% 100%;
}
.dress-item .pick-icon { width: 60%; height: 60%; color: var(--muted); }
.dress-item[aria-pressed="true"] .pick-icon { color: var(--accent); }
.dress-items.people { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.dress-items.people .dress-item { padding: 8px; }
/* Voices: 4 big tiles, each a colored shape with a short name; the picked one gets the outline and a check. */
.dress-items.voices { grid-template-columns: repeat(5, minmax(0, 1fr)); } /* 10 voices: two rows of five */
.dress-items.voices .dress-item { height: clamp(52px, 7.6vh, 84px); }
.voice-item { position: relative; grid-template-rows: minmax(0, 1fr) auto; gap: 2px; }
.voice-item .pick-icon { width: auto; height: 100%; max-height: 64px; aspect-ratio: 1; }
.voice-name { font-weight: 700; font-size: clamp(15px, 2.2vh, 20px); color: var(--ink, inherit); line-height: 1.1; }
.voice-item[aria-pressed="true"]::after {
  content: "\2713"; position: absolute; top: 4px; right: 6px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 800; display: grid; place-items: center;
}
/* Clothes: with 10 outfits the picker shows two rows of smaller tiles (still one screen, no scrolling). */
.dress-items.many .dress-item { height: clamp(48px, 7.2vh, 78px); }
/* Color palette: a round button in the stage corner; 8 big swatches fan out around it in a ring. */
.palette-btn {
  position: absolute; z-index: 7; right: 12px; top: 12px; width: 58px; height: 58px; border-radius: 50%; padding: 0; cursor: pointer;
  border: 3px solid #fff; background: radial-gradient(circle at 35% 30%, #8a6a4a, #5b4330); display: grid; place-items: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
.palette-btn[hidden] { display: none; }
.dress-stage.on-trip .palette-btn, .dress-stage.on-trip .palette-ring { display: none; } /* only while dressing */
.palette-btn svg { width: 36px; height: 36px; }
/* the 8 colors open as a wheel around the kid in the middle of the stage (big, easy, nothing to aim at) */
.palette-ring { position: absolute; z-index: 6; left: 50%; top: 50%; width: 0; height: 0; --r: min(34cqh, 30cqw); }
.palette-ring[hidden] { display: none; }
.palette-swatch {
  position: absolute; left: -29px; top: -29px; width: 58px; height: 58px; border-radius: 50%; padding: 0; cursor: pointer;
  border: 3px solid #fff; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3), inset 0 -6px 10px rgba(0, 0, 0, 0.15), inset 0 6px 8px rgba(255, 255, 255, 0.35);
  transform: rotate(var(--a)) translate(0) rotate(calc(-1 * var(--a))) scale(.4); opacity: 0;
  transition: transform 300ms cubic-bezier(0.22, 1, 0.36, 1) calc(var(--i) * 20ms), opacity 160ms ease;
}
.palette-ring.open .palette-swatch { opacity: 1; transform: rotate(calc(var(--a) - 90deg)) translate(var(--r)) rotate(calc(90deg - var(--a))); }
.palette-swatch[aria-checked="true"] { box-shadow: 0 0 0 5px var(--accent), 0 3px 10px rgba(0, 0, 0, 0.3); }
:root[data-motion="still"] .palette-swatch { transition: none; }
@media (max-width: 520px), (max-height: 520px) {
  .palette-btn { width: 50px; height: 50px; right: 10px; top: 10px; }
  .palette-swatch { width: 48px; height: 48px; left: -24px; top: -24px; }
}/* School trip: its own street world over the room; the dock steps aside so the street gets the whole screen.
   Two big round buttons on the stage: home (left) and next (right, the same spot as the bus button). */
.dress-stage.on-trip .world:not(.trip-world) { visibility: hidden; }
.dress-tools.trip-hidden { display: none; }
.trip-world { position: absolute; left: 0; top: 0; background-size: 100% 100%; transform-origin: 0 0; z-index: 2; overflow: hidden; }
.trip-world[hidden] { display: none; }
.trip-kid { position: absolute; max-width: none; pointer-events: none; transition: opacity 450ms ease; filter: drop-shadow(0 3px 3px rgba(40, 25, 15, 0.25)); }
.trip-crowd .trip-kid { transition: opacity 700ms ease; }
.trip-bus { position: absolute; transition: opacity 450ms ease; filter: drop-shadow(0 6px 6px rgba(30, 25, 20, 0.28)); }
.trip-bus > * { position: absolute; display: block; max-width: none; }
.bus-seats { left: 0; top: 0; width: 100%; height: 100%; }
.bus-hero { transition: opacity 500ms ease; }
.bus-body { left: 0; top: 0; width: 100%; }
.bus-body canvas { width: 100%; height: 100%; display: block; }
.bus-wheel { transform-origin: 50% 50%; }
.trip-btn {
  position: absolute; z-index: 6; bottom: 14px; width: 76px; height: 76px; border-radius: 50%; border: 3px solid #fff;
  display: grid; place-items: center; cursor: pointer; padding: 0; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}
.trip-btn[hidden] { display: none; }
.trip-btn svg { width: 40px; height: 40px; }
.trip-next { right: 14px; background: #F2B33D; color: #3a2a10; }
.trip-home { left: 14px; background: var(--surface-solid, #fff); color: var(--accent); }
.trip-btn:disabled { opacity: 0.45; cursor: default; }
.school-btn svg { width: 46px; height: 46px; }
@media (max-width: 520px), (max-height: 520px) { .trip-btn { width: 64px; height: 64px; bottom: 10px; } .trip-next { right: 10px; } .trip-home { left: 10px; } .trip-btn svg { width: 34px; height: 34px; } }
/* A real activity opened from a classroom station: it covers the whole stage and fades in after the close-up.
   Back to class sits top-left (the game's own buttons live along the bottom). Home and the room door step aside. */
.class-game { position: absolute; inset: 0; z-index: 8; opacity: 0; transition: opacity 220ms ease; background: var(--bg); }
.class-game[hidden] { display: none; }
.class-game.on { opacity: 1; }
.class-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; background: var(--bg); }
.class-back {
  position: absolute; z-index: 2; left: 10px; top: 10px; width: 56px; height: 56px; border-radius: 50%;
  border: 3px solid #fff; background: #F2B33D; color: #3a2a10; display: grid; place-items: center; cursor: pointer; padding: 0;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}
.class-back svg { width: 30px; height: 30px; }
.dress-stage.in-game .trip-home, .dress-stage.in-game .class-swap { visibility: hidden; }
:root[data-motion="still"] .class-game { transition: none; }
/* Classroom: the kid's own picture does the moving; one effects canvas on top; the tent dims the room softly. */
.class-world { touch-action: none; cursor: pointer; }
.class-kid { position: absolute; max-width: none; pointer-events: none; z-index: 2; filter: drop-shadow(0 4px 4px rgba(40, 25, 15, 0.25)); transform-origin: 50% 100%; }
.class-fx { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 3; }
.class-dim { position: absolute; inset: 0; background: rgba(20, 18, 40, 0.38); opacity: 0; transition: opacity 900ms ease; pointer-events: none; z-index: 1; }
.class-dim.on { opacity: 1; }
.class-kid.do-rock { animation: kid-rock 2.4s ease-in-out; }
.class-kid.do-sink { animation: kid-sink 1.4s ease-in-out; }
.class-kid.do-bounce { animation: kid-bounce 1.1s ease-in-out; }
.class-kid.do-swing { animation: kid-swing 3s ease-in-out; transform-origin: 50% -60%; }
@keyframes kid-rock { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-4deg); } 50% { transform: rotate(3deg); } 75% { transform: rotate(-2deg); } }
@keyframes kid-sink { 0%, 100% { transform: scaleY(1); } 40%, 60% { transform: scaleY(0.93) scaleX(1.03); } }
@keyframes kid-bounce { 0%, 100% { transform: translateY(0); } 15% { transform: translateY(3%) scaleY(0.97); } 45% { transform: translateY(-14%); } 75% { transform: translateY(2%) scaleY(0.98); } }
@keyframes kid-swing { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(6deg); } 50% { transform: rotate(-5deg); } 75% { transform: rotate(3deg); } }
:root[data-motion="still"] .class-kid { animation: none !important; }
.room-thumb { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; display: block; }
.dress-kid.bounce { transform: scale(1.015); }
:root[data-motion="still"] .dress-kid { transition: none; }

.dress-tools { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
.dress-tabs { display: flex; flex-direction: row; justify-content: center; gap: 10px; }
.dress-items.kids .dress-item { height: clamp(56px, 8.5vh, 84px); }
.dress-tab {
  width: 60px; height: 46px; border-radius: 16px; border: 2px solid var(--line); background: var(--surface); color: var(--muted);
  display: grid; place-items: center; cursor: pointer; padding: 0;
}
.dress-tab svg { width: 28px; height: 28px; }
.dress-tab[aria-selected="true"] { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.dress-items { flex: 1 1 auto; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; min-width: 0; }
.dress-item {
  height: clamp(72px, 13vh, 116px); min-width: 0; border-radius: 18px; border: 2px solid var(--line); background: var(--surface);
  display: grid; place-items: center; cursor: pointer; padding: 6px; overflow: hidden;
}
.dress-item canvas { width: 100%; height: 100%; object-fit: contain; display: block; min-width: 0; min-height: 0; }
.dress-item[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 30%, transparent); }
/* Phones upright: tabs sit in a row above the items so every item gets the full width (about 64 px each). */
@media (max-width: 520px) {
  .dress-tools { flex-direction: column; align-items: stretch; gap: 8px; }
  .dress-tabs { flex-direction: row; justify-content: center; gap: 10px; }
  .dress-tab { width: 48px; height: 46px; }
  .dress-tabs { gap: 6px; }
  .dress-items { gap: 6px; }
  .dress-item { height: clamp(64px, 10vh, 92px); padding: 3px; border-radius: 14px; }
}
/* Phones sideways (short screens): the picker moves beside Florence so she can be tall. */
@media (orientation: landscape) and (max-height: 520px) {
  main.activity.dress { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto minmax(0, 1fr); gap: 8px; }
  main.activity.dress > .act-head { grid-column: 1 / -1; }
  main.activity.dress > .dress-stage { grid-column: 1; grid-row: 2; }
  main.activity.dress > .dress-tools { grid-column: 2; grid-row: 2; flex-direction: column; align-items: stretch; width: min(46vw, 300px); margin: 0; }
  .dress-tabs { flex-direction: row; justify-content: center; gap: 5px; }
  .dress-tab { width: 42px; height: 42px; }
  .dress-tab svg { width: 24px; height: 24px; }
  .dress-items.voices { grid-template-columns: repeat(3, minmax(0, 1fr)); } .dress-items.voices .dress-item { height: clamp(40px, 13vh, 60px); }
  .dress-items { grid-template-columns: repeat(3, minmax(0, 1fr)); align-content: start; }
  .dress-item { height: clamp(64px, 26vh, 96px); }
  .dress-items.kids { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .dress-items.kids .dress-item { height: clamp(48px, 17vh, 72px); }
}

/* A school mini game is open and covers the stage: stop drawing the blurred background and the room under it. */
.dress-stage.game-on::before { display: none; }
.dress-stage.game-on .room-box { visibility: hidden; }
