/* ===========================================================================
   PRODIGIES WORLD · prodigies-world-v1.css
   Flat vector, warm rounded geometry, Chroma-Notes palette. Touch first:
   every control is at least 44px, nothing depends on hover, and the stage
   never scrolls the page by accident.
   =========================================================================== */

:root {
  --pw-paper:   #f5f2ea;
  --pw-card:    #fdfbf6;
  --pw-ink:     #1f1d1a;
  --pw-ink-2:   #6b6459;
  --pw-line:    #ddd6c8;
  --pw-navy:    #1b233e;
  --pw-teal:    #009999;
  --pw-red:     #e72829;
  --pw-orange:  #f39422;
  --pw-yellow:  #f1e606;
  --pw-green:   #6ab845;
  --pw-blue:    #1e7fc3;
  --pw-purple:  #7b569e;
  --pw-pink:    #ea6ba3;
  --pw-brown:   #512d1b;

  --pw-r:   18px;
  --pw-r-s: 12px;
  --pw-shadow:   0 2px 0 rgba(31,29,26,.08), 0 8px 20px rgba(31,29,26,.10);
  --pw-shadow-l: 0 4px 0 rgba(31,29,26,.10), 0 20px 44px rgba(31,29,26,.18);
  --pw-topbar-h: 62px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--pw-paper);
  color: var(--pw-ink);
  font-family: 'Nunito', system-ui, -apple-system, sans-serif;
  /* Stop the whole page rubber-banding while a child drags a couch. */
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}
body.pw-dragging { cursor: grabbing; user-select: none; -webkit-user-select: none; }

.pw-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── app frame ───────────────────────────────────────────────────────────── */
.pw-app {
  position: relative;              /* the modal layer is scoped to the app... */
  display: flex; flex-direction: column;
  height: 100dvh; min-height: 0;
  overflow: hidden;
}

/* ── top bar ─────────────────────────────────────────────────────────────── */
.pw-topbar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 14px;
  height: var(--pw-topbar-h);
  padding: 0 14px;
  background: var(--pw-navy);
  color: #fdfbf6;
  position: relative; z-index: 40;
}
/* No rainbow strip here. The canonical one is the shared, page-fixed bar in
   assets/rainbow-bar.css, loaded by index.html — a second one under the topbar
   made two on screen at once. One bar, one file, one place to change it. */
.pw-brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.pw-brand-mark { font-size: 24px; line-height: 1; }
.pw-brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.pw-brand-text b { font-weight: 900; font-size: 15px; letter-spacing: -.2px; }
.pw-brand-text i { font-style: normal; font-size: 11px; opacity: .68; }

.pw-rooms { display: flex; gap: 6px; margin-left: 6px; }
.pw-roombtn {
  appearance: none; border: 0; cursor: pointer;
  min-height: 38px; padding: 0 14px; border-radius: 999px;
  background: rgba(253,251,246,.12); color: #fdfbf6;
  font: 800 13px/1 'Nunito', sans-serif;
}
.pw-roombtn:hover { background: rgba(253,251,246,.22); }
.pw-roombtn:active { transform: translateY(1px); }

.pw-topactions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.pw-btn {
  appearance: none; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 44px; padding: 0 16px; border-radius: 999px;
  font: 800 14px/1 'Nunito', sans-serif;
  transition: transform .08s ease, filter .15s ease;
}
.pw-btn:active { transform: translateY(1px); }
.pw-btn-primary { background: var(--pw-teal); color: #fff; box-shadow: 0 3px 0 #00706f; }
.pw-btn-primary:hover { filter: brightness(1.06); }
.pw-btn-done { background: var(--pw-green); box-shadow: 0 3px 0 #4f9a34; }
.pw-btn-ghost { background: rgba(253,251,246,.14); color: #fdfbf6; }
.pw-btn-danger { background: var(--pw-red); color: #fff; box-shadow: 0 3px 0 #b41f20; }

.pw-iconbtn {
  appearance: none; border: 0; cursor: pointer;
  width: 44px; height: 44px; border-radius: 999px;
  background: rgba(253,251,246,.14); color: #fdfbf6;
  font-size: 17px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.pw-iconbtn:active { transform: translateY(1px); }

/* ── coins ───────────────────────────────────────────────────────────────── */
.pw-purse {
  appearance: none; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 15px; border-radius: 999px;
  background: #3a3320; color: #ffd25b;
  font: 900 15px/1 'Nunito', sans-serif;
  box-shadow: inset 0 0 0 2px rgba(255,210,91,.35);
}
.pw-purse[hidden] { display: none; }
.pw-purse:active { transform: translateY(1px); }
.pw-purse b { font-weight: 900; font-size: 16px; min-width: 1ch; }
.pw-coin { width: 1.05em; height: 1.05em; display: inline-block; vertical-align: -.16em; flex: 0 0 auto; }
.pw-purse .pw-coin { width: 19px; height: 19px; }
.pw-price .pw-coin { width: 12px; height: 12px; margin-right: 3px; }
.pw-buy-price .pw-coin { width: 26px; height: 26px; margin-right: 5px; }
.pw-purse-big .pw-coin { width: 38px; height: 38px; margin-right: 7px; }
.pw-buy-math .pw-coin { width: 15px; height: 15px; margin-right: 2px; }
.pw-btn .pw-coin { width: 16px; height: 16px; margin: 0 1px 0 3px; }

/* The price chip. Locked tiles are shown at FULL colour with this chip —
   never dimmed. Dim reads as "broken" to a five-year-old; a gold coin reads
   as "you could have this". Grey = not affordable yet, gold = you can. */
.pw-price {
  position: absolute; top: 4px; right: 4px;
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px 8px; border-radius: 999px;
  font: 900 11px/1 'Nunito', sans-serif;
  background: #3a3320; color: #cfc6b0;
  box-shadow: 0 1px 4px rgba(31,29,26,.28);
  pointer-events: none;
}
.pw-traytile.can-afford .pw-price { background: #ffd25b; color: #512d1b; }
.pw-traytile.is-locked, .pw-opt.is-locked { position: relative; }
.pw-traytile.is-locked { border-style: dashed; }
.pw-opt.is-locked { border-style: dashed; }
.pw-optrow .pw-opt.is-locked .pw-price,
.pw-optgrid .pw-opt.is-locked .pw-price { top: 2px; right: 2px; padding: 2px 6px; font-size: 10px; }

/* buy sheet */
.pw-sheet-buy { text-align: center; align-items: center; }
.pw-buy-art { width: 130px; height: 110px; margin: 4px auto 10px; display: grid; place-items: center; }
.pw-buy-art svg, .pw-buy-art img { max-width: 100%; max-height: 110px; overflow: visible; }
.pw-buy-price { margin: 0 0 6px; font: 900 26px/1 'Nunito', sans-serif; color: var(--pw-ink); }
.pw-buy-math { margin: 0 0 4px; font-size: 14px; color: var(--pw-ink-2); }
.pw-buy-math b { color: var(--pw-ink); }
.pw-buy-short b { color: var(--pw-red); }
.pw-sheet-buy .pw-sheet-actions { justify-content: center; flex-wrap: wrap; }
.pw-sheet-buy a.pw-btn { text-decoration: none; }

/* purse sheet */
.pw-purse-big { margin: 6px 0 10px; font: 900 40px/1 'Nunito', sans-serif; color: var(--pw-ink); text-align: center; }
.pw-purse-hint { margin: 0 0 12px; text-align: center; color: var(--pw-ink-2); font-size: 14px; line-height: 1.5; }
.pw-purse-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; max-height: 46vh; overflow-y: auto; }
.pw-purse-log li { display: flex; gap: 10px; font-size: 14px; font-weight: 700; color: var(--pw-ink-2); }
.pw-purse-log li span { font-weight: 900; min-width: 3.4ch; text-align: right; }
.pw-purse-log li.is-earn span { color: #4f9a34; }
.pw-purse-log li.is-spend span { color: var(--pw-red); }
.pw-purse-warn {
  margin: 12px 0 0; padding: 9px 12px; border-radius: 12px;
  background: #fdf0c6; color: #7a5a12; font-size: 13px; font-weight: 800; text-align: center;
}
.pw-sheet-purse a.pw-btn { text-decoration: none; }

/* ── stage ───────────────────────────────────────────────────────────────── */
.pw-main { position: relative; flex: 1 1 auto; min-height: 0; }
.pw-sceneholder, .pw-scene { position: absolute; inset: 0; }

.pw-scroller {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  overflow-x: auto; overflow-y: hidden;
  background:
    radial-gradient(120% 80% at 50% 0%, #eaf3f6 0%, #dfeaef 55%, #d3e2e8 100%);
  /* horizontal pan only — vertical touch must never scroll the page */
  touch-action: pan-x;
  -webkit-overflow-scrolling: touch;
}
.pw-scroller.is-panning { justify-content: flex-start; }
.pw-sceneholder[hidden] { display: none; }
.pw-stage-wrap { flex: 0 0 auto; position: relative; }
.pw-stage {
  position: absolute; top: 0; left: 0;
  transform-origin: 0 0;
  will-change: transform;
}
.pw-house-layer, .pw-objects { position: absolute; inset: 0; }
.pw-house-layer { pointer-events: none; }
.pw-house { position: absolute; inset: 0; width: 100%; height: 100%; }
.pw-house .pw-dark { transition: opacity .3s ease; }

/* ── the world map ───────────────────────────────────────────────────────── */
.pw-map {
  position: absolute; inset: 0; z-index: 5;
  overflow-y: auto; overflow-x: hidden;
  background:
    radial-gradient(120% 90% at 50% 0%, #cfe9f5 0%, #b9dced 46%, #9fd0a8 47%, #8fc79b 100%);
  display: grid; place-items: center;
  padding: 24px 16px 32px;
}
.pw-map[hidden] { display: none; }

/* The village behind the buttons. Fixed scene, letterboxed with slice, and
   pointer-events off so scenery can never eat a tap meant for a house. */
.pw-map-scenery { position: absolute; inset: 0; pointer-events: none; }
.pw-map-scenery svg { width: 100%; height: 100%; display: block; }
.pwm-cloud { animation: pwm-drift 46s ease-in-out infinite alternate; }
.pwm-cloud-b { animation-duration: 64s; animation-delay: -20s; }
@keyframes pwm-drift {
  from { transform: translateX(-40px); }
  to   { transform: translateX(60px); }
}
@media (prefers-reduced-motion: reduce) { .pwm-cloud { animation: none; } }

.pw-map-inner { width: 100%; max-width: 1200px; position: relative; z-index: 1; }
.pw-map-title {
  margin: 0 0 18px; text-align: center;
  font: 900 clamp(20px, 3.2vw, 30px)/1.15 'Nunito', sans-serif; color: var(--pw-navy);
  text-shadow: 0 2px 0 rgba(255,255,255,.5);
}
.pw-map-row {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  align-items: stretch;
}
.pw-building {
  appearance: none; border: 0; cursor: pointer; font-family: inherit; color: inherit;
  /* Light enough that the village shows through around the row; the border
     keeps each card readable on top of grass and path alike. */
  background: rgba(253, 251, 246, 0.72);
  border: 2px solid rgba(255, 255, 255, 0.65);
  border-radius: 22px; padding: 12px 12px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  box-shadow: var(--pw-shadow);
  transition: transform .12s cubic-bezier(.3,1.4,.4,1), box-shadow .12s ease;
}
.pw-building:hover { transform: translateY(-4px); box-shadow: var(--pw-shadow-l); }
.pw-building:active { transform: translateY(1px); }
.pw-building-art {
  display: block; width: 100%; max-width: 260px;
  /* Fixed height + a bottom-anchored viewBox gives all three buildings a
     common ground line, so the names and blurbs align across the row. */
  height: clamp(140px, 22vh, 210px);
}
.pw-building-art svg { width: 100%; height: 100%; display: block; overflow: visible; }
.pw-building-name { font: 900 18px/1.2 'Nunito', sans-serif; margin-top: 6px; text-align: center; }
.pw-building-blurb { font-size: 12.5px; color: var(--pw-ink-2); text-align: center; line-height: 1.35; }
.pw-building-who { margin-top: auto; }
.pw-building-who {
  margin-top: 6px; font: 800 11px/1 'Nunito', sans-serif;
  background: var(--pw-teal); color: #fff; padding: 4px 10px; border-radius: 999px;
}
@media (prefers-reduced-motion: reduce) { .pw-building { transition: none; } }

/* The Map button and the room chips are one nav; highlight where you are. */
.pw-roombtn.is-on { background: var(--pw-teal); color: #fff; }
.pw-mapbtn { display: inline-flex; align-items: center; gap: 6px; }

/* Decorate + Characters are room actions; hide them on the map so the first
   screen is only ever "pick a place". */
.pw-app[data-view="map"] #pwModeBtn,
.pw-app[data-view="map"] #pwCharsBtn { display: none; }

/* Wall-hung things cast a little shadow down the wall — the cheap half of the
   grounding pass (floor items get an ellipse drawn into their own art). The
   filter follows the art's silhouette, so a round clock and a square poster
   each get the right shadow for free. */
.pw-obj-item.pw-place-wall .pw-item-art {
  filter: drop-shadow(0 5px 4px rgba(27, 35, 62, 0.16));
}

/* ── objects ─────────────────────────────────────────────────────────────── */
.pw-obj {
  position: absolute;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.pw-obj-art, .pw-char-art { position: absolute; inset: 0; }
.pw-obj-art svg, .pw-char-art svg { width: 100%; height: 100%; display: block; overflow: visible; }
.pw-obj img { pointer-events: none; }

.pw-draggable { cursor: grab; }
.pw-draggable:active { cursor: grabbing; }
.pw-obj.is-dragging {
  cursor: grabbing;
  filter: drop-shadow(0 14px 18px rgba(31,29,26,.32));
  transition: none;
}
.pw-obj.is-dragging .pw-obj-art,
.pw-obj.is-dragging .pw-char-art { pointer-events: none; }

.pw-obj.is-selected::after {
  content: ""; position: absolute; inset: -10px;
  border: 4px dashed var(--pw-teal); border-radius: 16px;
  pointer-events: none;
  animation: pw-marching 1.2s linear infinite;
}
@keyframes pw-marching { to { border-color: #00c2c2; } }

.pw-obj-char[data-pose="lie"] .pw-char-art {
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}

/* held object */
.pw-held { position: absolute; pointer-events: auto; touch-action: none; }
.pw-held svg { width: 100%; height: 100%; display: block; overflow: visible; }

/* sub-hit targets (piano keys, deskbells, xylophone bars, mat slots) */
.pw-subhits { position: absolute; inset: 0; }
.pw-hit {
  position: absolute; appearance: none; border: 0; padding: 0;
  background: transparent; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
.pw-key.is-hit { background: rgba(0,153,153,.42); border-radius: 3px; }
.pw-key-black { z-index: 2; }
.pw-bar.is-hit { background: rgba(255,255,255,.55); border-radius: 4px; }

.pw-rackbell img { width: 100%; height: 100%; display: block; pointer-events: none; }
.pw-rackbell { transition: transform .09s ease; }
.pw-rackbell.is-hit { transform: translateY(-7px) scale(1.05); }

.pw-matslot { position: absolute; border-radius: 12px; pointer-events: none; }
.pw-matslot.is-live {
  background: rgba(255,255,255,.55);
  box-shadow: 0 0 0 5px rgba(255,255,255,.42);
}

.pw-roomflash {
  position: absolute; pointer-events: none; border-radius: 14px;
  box-shadow: inset 0 0 0 8px rgba(0,153,153,.7);
  animation: pw-flash .9s ease forwards;
}
@keyframes pw-flash { 0%,60% { opacity: 1; } 100% { opacity: 0; } }

/* ── the Music Mat play button (lives inside the stage, in world units) ──── */
.pw-overlays { position: absolute; inset: 0; pointer-events: none; }
.pw-matplay {
  position: absolute;
  appearance: none; border: 0; cursor: pointer;
  border-radius: 999px;
  background: var(--pw-teal); color: #fff;
  box-shadow: 0 7px 0 #00706f, 0 14px 30px rgba(31,29,26,.28);
  display: grid; place-items: center;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.pw-matplay svg { width: 52%; height: 52%; }
.pw-matplay:active { transform: translateY(2px); }
.pw-matplay.is-playing { background: var(--pw-red); box-shadow: 0 7px 0 #b41f20, 0 14px 30px rgba(31,29,26,.28); }
.pw-matplay.is-playing svg { display: none; }
.pw-matplay.is-playing::after { content: ""; width: 34%; height: 34%; border-radius: 8px; background: #fff; }

/* particles */
.pw-notepop {
  position: absolute; pointer-events: none;
  font-size: 40px; font-weight: 900; line-height: 1;
  text-shadow: 0 2px 0 rgba(255,255,255,.6);
  animation: pw-float 1.4s cubic-bezier(.2,.7,.3,1) forwards;
  animation-delay: var(--pw-delay, 0ms);
  opacity: 0;
}
@keyframes pw-float {
  0%   { opacity: 0; transform: translate(0, 0) scale(.5); }
  18%  { opacity: 1; transform: translate(0, -18px) scale(1.1); }
  100% { opacity: 0; transform: translate(var(--pw-drift, 0), -150px) scale(.9); }
}

.pw-bug { position: absolute; width: 46px; height: 46px; pointer-events: none; animation: pw-bugfly 2.6s ease-out forwards; }
.pw-bug svg { width: 100%; height: 100%; }
@keyframes pw-bugfly {
  0% { opacity: 0; transform: translate(0,0) scale(.4) rotate(0deg); }
  15% { opacity: 1; transform: translate(10px,-40px) scale(1) rotate(-12deg); }
  55% { transform: translate(90px,-130px) scale(1) rotate(14deg); }
  100% { opacity: 0; transform: translate(210px,-210px) scale(.8) rotate(-8deg); }
}

.pw-glownotes { position: absolute; pointer-events: none; }
.pw-glownotes span {
  position: absolute; color: #9fe9ff; font-weight: 900;
  text-shadow: 0 0 14px rgba(159,233,255,.9), 0 0 30px rgba(120,200,255,.6);
  animation: pw-glowpulse 3.4s ease-in-out infinite;
  animation-delay: var(--pw-delay, 0ms);
}
@keyframes pw-glowpulse { 0%,100% { opacity: .35; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-8px); } }

/* reactions */
.pw-react-bounce { animation: pw-bounce .6s cubic-bezier(.3,1.4,.4,1); }
.pw-react-sing   { animation: pw-bounce .6s cubic-bezier(.3,1.6,.4,1) 2; }
.pw-hop          { animation: pw-bounce .5s cubic-bezier(.3,1.5,.4,1); }
@keyframes pw-bounce { 0%,100% { transform: translateY(0); } 35% { transform: translateY(-16px); } 60% { transform: translateY(2px); } }

.pw-react-glow { animation: pw-glow .6s ease; }
@keyframes pw-glow {
  0%   { filter: none; transform: scale(1); }
  35%  { filter: drop-shadow(0 0 22px rgba(255,255,255,.95)) brightness(1.22); transform: scale(1.1); }
  100% { filter: none; transform: scale(1); }
}

/* ── aliveness ────────────────────────────────────────────────────────────
   Three behaviours that cost no artwork at all, and between them do most of
   the work of making a room feel inhabited. All of them use the standalone
   `scale`/`transform` split deliberately: the press uses `scale` on .pw-obj
   and breathing uses `transform` on the inner art node, so neither can
   collide with the reaction keyframes above (which own `transform` on
   .pw-obj) or with the inline scaleX(-1) that mirrors a flipped item.
   ------------------------------------------------------------------------ */

/* 1. Press feedback on every object, interactive or not. */
.pw-obj { transition: scale .13s cubic-bezier(.3,1.5,.4,1); }
.pw-obj.is-pressed { scale: .94; }
.pw-obj.is-dragging { scale: 1; transition: none; }

/* 2. Blink. The closed frame is ~2% of the cycle, which is what stops it
      reading as a twitch. Each character carries its own delay. */
.pw-l-eyes {
  animation: pw-blink 6.4s infinite;
  animation-delay: var(--pw-blink-delay, 0ms);
  transform-origin: 100px 70px;
}
@keyframes pw-blink {
  0%, 95%, 100% { transform: scaleY(1); }
  97.5%         { transform: scaleY(.08); }
}

/* 3. Idle breathing. Excluded for the lie pose, which owns .pw-char-art's
      transform for its -90deg rotation. */
.pw-obj-char:not([data-pose="lie"]) .pw-char-art {
  animation: pw-breathe 4.2s ease-in-out infinite;
  animation-delay: var(--pw-breathe-delay, 0ms);
}
@keyframes pw-breathe { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-2.5px); } }

.pw-shake  { animation: pw-shake .45s ease; }
@keyframes pw-shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-6px) rotate(-2deg); } 50% { transform: translateX(6px) rotate(2deg); } 80% { transform: translateX(-3px); } }
.pw-wiggle { animation: pw-wiggle .6s ease; }
@keyframes pw-wiggle { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-5deg) scale(1.04); } 75% { transform: rotate(5deg) scale(1.04); } }

/* Calm mode / OS reduced-motion: kill decorative movement, keep the drag. */
.pw-calm .pw-notepop, .pw-calm .pw-bug, .pw-calm .pw-glownotes span { display: none; }
.pw-calm .pw-react-bounce, .pw-calm .pw-react-glow, .pw-calm .pw-react-sing,
.pw-calm .pw-shake, .pw-calm .pw-wiggle, .pw-calm .pw-hop { animation: none; }
.pw-calm .pw-l-eyes, .pw-calm .pw-obj-char .pw-char-art { animation: none; }
.pw-calm .pw-obj { transition: none; }
.pw-calm .pw-obj.is-pressed { scale: 1; }
@media (prefers-reduced-motion: reduce) {
  .pw-notepop, .pw-bug { display: none; }
  .pw-react-bounce, .pw-react-glow, .pw-react-sing, .pw-shake, .pw-wiggle, .pw-hop,
  .pw-glownotes span, .pw-roomflash { animation: none; }
  .pw-obj.is-selected::after { animation: none; }
  .pw-l-eyes, .pw-obj-char .pw-char-art { animation: none; }
  .pw-obj { transition: none; }
  .pw-obj.is-pressed { scale: 1; }
}

/* ── toast ───────────────────────────────────────────────────────────────── */
.pw-toast {
  position: absolute; left: 50%; bottom: 22px; transform: translate(-50%, 16px);
  background: var(--pw-navy); color: #fdfbf6;
  padding: 12px 20px; border-radius: 999px;
  font: 800 14px/1.2 'Nunito', sans-serif;
  box-shadow: var(--pw-shadow-l);
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
  max-width: min(88vw, 460px); text-align: center;
  z-index: 45;
}
.pw-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ── action bar ──────────────────────────────────────────────────────────── */
.pw-actionbar {
  flex: 0 0 auto; z-index: 42;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center;
  background: var(--pw-card); border-top: 3px solid var(--pw-line);
  padding: 8px 12px;
  box-shadow: 0 -6px 18px rgba(31,29,26,.08);
}
.pw-actionbar[hidden] { display: none; }
.pw-actionbar .pw-btn-ghost { background: #efe9dc; color: var(--pw-ink); }
.pw-actionbar-name { font-weight: 900; font-size: 14px; padding: 0 8px; color: var(--pw-ink-2); }
.pw-facepicker { display: flex; gap: 4px; }
.pw-faceb {
  appearance: none; border: 2px solid transparent; cursor: pointer;
  width: 44px; height: 44px; border-radius: 999px; background: #efe9dc; font-size: 20px;
}
.pw-faceb.is-on { border-color: var(--pw-teal); background: #d9f0f0; }

/* ── character drawer ────────────────────────────────────────────────────── */
.pw-drawer {
  flex: 0 0 auto; background: var(--pw-card);
  border-top: 3px solid var(--pw-line);
  padding: 12px 14px 14px;
  box-shadow: 0 -10px 30px rgba(31,29,26,.10);
  z-index: 38;
  /* Bounded in px as well as vh: this game is embedded, so the app box is a
     lot shorter than the viewport and a pure vh cap swallows the house. */
  max-height: min(38dvh, 230px); overflow-y: auto;
}
.pw-drawer[hidden] { display: none; }
.pw-drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.pw-drawer-head h2 { margin: 0; font-size: 16px; font-weight: 900; }
.pw-drawer .pw-iconbtn { background: #efe9dc; color: var(--pw-ink); }
.pw-drawer-hint { margin: 10px 0 0; font-size: 12px; color: var(--pw-ink-2); }

.pw-charlist { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.pw-charcard {
  flex: 0 0 auto; position: relative;
  width: 116px; border-radius: var(--pw-r); border: 2px solid var(--pw-line);
  background: #fff; padding: 8px 6px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  appearance: none; cursor: pointer; font-family: inherit; color: inherit;
}
.pw-charcard.is-in { border-color: var(--pw-teal); background: #f0fafa; }
.pw-charcard-main {
  appearance: none; border: 0; background: none; cursor: pointer; padding: 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px; width: 100%;
  font-family: inherit; color: inherit;
}
.pw-charcard-art { display: block; width: 74px; height: 92px; }
.pw-charcard-art svg { width: 100%; height: 100%; overflow: visible; }
.pw-charcard-name { font-weight: 900; font-size: 12px; text-align: center; line-height: 1.15; }
.pw-charcard-sub { font-size: 10px; color: var(--pw-ink-2); }
.pw-charcard-tools { display: flex; gap: 4px; margin-top: 4px; }
.pw-charcard-tools .pw-iconbtn { width: 34px; height: 34px; font-size: 13px; background: #efe9dc; color: var(--pw-ink); }
.pw-charnew { justify-content: center; min-height: 132px; border-style: dashed; background: #faf7f0; }
.pw-charnew-mark { font-size: 30px; color: var(--pw-teal); }
.pw-charnew-bell .pw-charnew-mark { color: var(--pw-red); }
.pw-empty { color: var(--pw-ink-2); font-size: 13px; align-self: center; }

/* ── decorating tray ─────────────────────────────────────────────────────── */
.pw-tray {
  flex: 0 0 auto; background: var(--pw-card);
  border-top: 3px solid var(--pw-line);
  box-shadow: 0 -10px 30px rgba(31,29,26,.10);
  z-index: 39;
}
.pw-tray[hidden] { display: none; }
.pw-tray-tabs {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px; border-bottom: 2px solid var(--pw-line);
  overflow-x: auto;
}
.pw-tray-spacer { flex: 1 1 auto; }
.pw-tab {
  appearance: none; border: 0; cursor: pointer; white-space: nowrap;
  min-height: 40px; padding: 0 14px; border-radius: 999px;
  background: #efe9dc; color: var(--pw-ink);
  font: 800 13px/1 'Nunito', sans-serif;
}
.pw-tab.is-on { background: var(--pw-navy); color: #fdfbf6; }
.pw-tray-tabs .pw-btn-ghost { background: #efe9dc; color: var(--pw-ink); min-height: 40px; }

.pw-tray-body { padding: 12px; max-height: min(30dvh, 200px); overflow-y: auto; }
.pw-tray-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.pw-traytile {
  appearance: none; cursor: grab; font-family: inherit; color: inherit;
  border: 2px solid var(--pw-line); border-radius: var(--pw-r-s);
  background: #fff; padding: 8px 6px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  touch-action: none;
}
.pw-traytile:active { transform: translateY(1px); }
.pw-traytile.is-used, .pw-traytile[disabled] { opacity: .38; cursor: default; }
.pw-traytile-art { width: 100%; height: 66px; display: block; }
.pw-traytile-art svg, .pw-traytile-art img { width: 100%; height: 100%; object-fit: contain; }
.pw-traytile-name { font-size: 11px; font-weight: 800; text-align: center; line-height: 1.15; }

.pw-trayghost {
  position: fixed; z-index: 9999; pointer-events: none;
  opacity: .9; filter: drop-shadow(0 12px 16px rgba(31,29,26,.3));
}
.pw-trayghost svg { width: 100%; height: 100%; overflow: visible; }

/* finishes */
.pw-tray-finish { display: flex; flex-direction: column; gap: 12px; }
.pw-finish-rooms { display: flex; gap: 6px; flex-wrap: wrap; }
.pw-chip {
  appearance: none; border: 2px solid var(--pw-line); cursor: pointer;
  min-height: 40px; padding: 0 14px; border-radius: 999px;
  background: #fff; font: 800 13px/1 'Nunito', sans-serif; color: inherit;
}
.pw-chip.is-on { background: var(--pw-teal); border-color: var(--pw-teal); color: #fff; }
.pw-finish-group h3 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--pw-ink-2); }
.pw-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.pw-swatch {
  appearance: none; border: 3px solid transparent; cursor: pointer;
  border-radius: var(--pw-r-s); background: none; padding: 3px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-family: inherit; color: inherit;
}
.pw-swatch i {
  display: block; width: 56px; height: 44px; border-radius: 9px;
  background: linear-gradient(160deg, var(--sw) 0 62%, var(--sw2) 62% 100%);
  border: 2px solid rgba(31,29,26,.14);
}
.pw-swatch span { font-size: 11px; font-weight: 800; }
.pw-swatch.is-on { border-color: var(--pw-teal); }

/* ── modal sheets ────────────────────────────────────────────────────────── */
/* ...absolute, not fixed: this game is embedded in the PK-5 shell, and a
   viewport-fixed overlay would centre itself behind the platform sidebar. */
.pw-modal {
  position: absolute; inset: 0; z-index: 60;
  background: rgba(27,35,62,.5);
  display: grid; place-items: center;
  padding: 14px;
}
.pw-modal[hidden] { display: none; }
.pw-sheet {
  background: var(--pw-card); border-radius: 22px;
  box-shadow: var(--pw-shadow-l);
  width: min(1020px, 100%); max-height: 100%;
  display: flex; flex-direction: column; overflow: hidden;
}
.pw-sheet-small { width: min(460px, 100%); padding: 20px; gap: 8px; overflow-y: auto; }
.pw-sheet-small h2 { margin: 0 0 4px; font-size: 19px; font-weight: 900; }
.pw-sheet-small p { margin: 0 0 10px; color: var(--pw-ink-2); font-size: 14px; line-height: 1.5; }
.pw-sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 2px solid var(--pw-line); flex: 0 0 auto;
}
.pw-sheet-head h2 { margin: 0; font-size: 18px; font-weight: 900; }
.pw-sheet-head-actions { display: flex; align-items: center; gap: 8px; }
.pw-sheet-head .pw-iconbtn, .pw-sheet-small .pw-iconbtn { background: #efe9dc; color: var(--pw-ink); }
.pw-sheet-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

/* ── creator ─────────────────────────────────────────────────────────────── */
.pw-creator { display: grid; grid-template-columns: 300px 1fr; min-height: 0; flex: 1 1 auto; }
.pw-creator-preview {
  padding: 16px; border-right: 2px solid var(--pw-line);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  background: linear-gradient(180deg, #f0f7f8, #e6eff2);
}
.pw-preview-art { width: 190px; height: 300px; display: grid; place-items: center; }
.pw-preview-art svg { width: 100%; height: 100%; overflow: visible; }
.pw-nameline { width: 100%; }
.pw-nameline input {
  width: 100%; min-height: 46px; border-radius: 12px;
  border: 2px solid var(--pw-line); background: #fff;
  padding: 0 14px; font: 800 15px 'Nunito', sans-serif; color: inherit;
  text-align: center;
}
.pw-nameline input:focus { outline: 3px solid var(--pw-teal); outline-offset: 1px; }
.pw-deletechar { align-self: stretch; justify-content: center; }

.pw-creator-pick { display: flex; flex-direction: column; min-height: 0; }
.pw-cattabs {
  display: flex; gap: 6px; padding: 10px 12px;
  border-bottom: 2px solid var(--pw-line); overflow-x: auto; flex: 0 0 auto;
}
.pw-cattab {
  appearance: none; border: 0; cursor: pointer; white-space: nowrap;
  min-height: 46px; padding: 0 14px; border-radius: 999px;
  background: #efe9dc; color: var(--pw-ink);
  display: inline-flex; align-items: center; gap: 6px;
  font: 800 13px/1 'Nunito', sans-serif;
}
.pw-cattab.is-on { background: var(--pw-navy); color: #fdfbf6; }

.pw-catbody { padding: 14px; overflow-y: auto; flex: 1 1 auto; }
.pw-catbody h3 { margin: 14px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--pw-ink-2); }
.pw-catbody h3:first-child { margin-top: 0; }
.pw-note { margin: 0 0 10px; font-size: 13px; color: var(--pw-ink-2); }

.pw-optgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.pw-optgrid-wide { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.pw-optgrid-bells { grid-template-columns: repeat(auto-fill, minmax(94px, 1fr)); }
.pw-opt {
  appearance: none; cursor: pointer; font-family: inherit; color: inherit;
  border: 3px solid var(--pw-line); border-radius: var(--pw-r-s);
  background: #fff; padding: 6px 4px 4px; min-height: 44px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.pw-opt svg, .pw-opt img { width: 100%; height: 62px; object-fit: contain; display: block; }
.pw-optgrid-wide .pw-opt svg { height: 104px; }
.pw-opt-name { font-size: 10px; font-weight: 800; text-align: center; line-height: 1.15; color: var(--pw-ink-2); }
.pw-opt.is-on { border-color: var(--pw-teal); background: #f0fafa; }
.pw-opt.is-on .pw-opt-name { color: var(--pw-ink); }
.pw-opt-bell.is-on { border-color: var(--c, var(--pw-teal)); }

.pw-colorrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.pw-color {
  appearance: none; cursor: pointer; padding: 0;
  width: 44px; height: 44px; border-radius: 999px;
  border: 3px solid rgba(31,29,26,.14); background: var(--c);
}
.pw-color.is-on { border-color: var(--pw-navy); box-shadow: 0 0 0 3px #fff inset; }

/* ── wardrobe ────────────────────────────────────────────────────────────── */
.pw-wardrobe { display: grid; grid-template-columns: 210px 1fr; min-height: 0; flex: 1 1 auto; }
.pw-wardrobe-preview {
  padding: 14px; border-right: 2px solid var(--pw-line);
  display: grid; place-items: center;
  background: linear-gradient(180deg, #f0f7f8, #e6eff2);
}
.pw-wardrobe-preview svg { width: 150px; height: 250px; overflow: visible; }
.pw-wardrobe-picks { padding: 12px 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.pw-wardrobe-row h3 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--pw-ink-2); }
.pw-optrow { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.pw-optrow .pw-opt { flex: 0 0 auto; width: 78px; }
.pw-optrow .pw-opt svg { height: 56px; }

/* ── settings ────────────────────────────────────────────────────────────── */
.pw-setting { display: flex; align-items: center; gap: 10px; min-height: 46px; font-weight: 800; font-size: 14px; }
.pw-setting input[type="checkbox"] { width: 24px; height: 24px; accent-color: var(--pw-teal); }
.pw-setting-range { display: grid; grid-template-columns: 90px 1fr; align-items: center; }
.pw-setting-range input { width: 100%; accent-color: var(--pw-teal); }
.pw-secrets-title { margin: 16px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--pw-ink-2); }
.pw-secrets { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.pw-secrets li.is-found { font-weight: 800; }
.pw-secret-hidden { color: var(--pw-ink-2); font-style: italic; }

/* ── focus visibility (keyboard users) ───────────────────────────────────── */
:where(button, input, [tabindex]):focus-visible {
  outline: 3px solid var(--pw-teal);
  outline-offset: 2px;
  border-radius: 8px;
}
.pw-topbar :where(button):focus-visible { outline-color: #ffd25b; }

/* ── responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .pw-creator { grid-template-columns: 1fr; }
  .pw-creator-preview {
    border-right: 0; border-bottom: 2px solid var(--pw-line);
    flex-direction: row; align-items: center; gap: 14px; padding: 12px;
  }
  .pw-preview-art { width: 110px; height: 176px; flex: 0 0 auto; }
  .pw-nameline { flex: 1 1 auto; }
  .pw-deletechar { align-self: center; }
  .pw-wardrobe { grid-template-columns: 1fr; }
  .pw-wardrobe-preview { border-right: 0; border-bottom: 2px solid var(--pw-line); padding: 10px; }
  .pw-wardrobe-preview svg { width: 96px; height: 160px; }
}

/* The room nav adds four more chips, so the brand text has to go sooner. */
@media (max-width: 1000px) { .pw-brand-text { display: none; } }

@media (max-width: 720px) {
  .pw-btn-label { display: none; }
  .pw-btn { padding: 0 14px; }
  .pw-rooms { margin-left: 0; }
  .pw-roombtn { padding: 0 11px; font-size: 12px; }
  .pw-topbar { gap: 8px; padding: 0 10px; }
}

@media (max-width: 520px) {
  /* The house is wider than a phone, so it pans — which means the room
     buttons are the main way to get around. Give them their own row rather
     than dropping them. */
  .pw-topbar { height: auto; flex-wrap: wrap; padding: 8px 10px; row-gap: 8px; }
  .pw-rooms { order: 3; width: 100%; justify-content: space-between; }
  .pw-roombtn { flex: 1 1 0; min-height: 40px; }
  .pw-tray-body { max-height: min(28dvh, 170px); }
  .pw-charcard { width: 100px; }
  .pw-actionbar { gap: 6px; padding: 6px 8px; }
}
