/* Cosy Room — namespaced under .cosy-room-app */
    .cosy-room-app *, .cosy-room-app *::before, .cosy-room-app *::after{ margin: 0; padding: 0; box-sizing: border-box; }

    .cosy-room-app{
      /* Warmer, more muted "evening / golden hour" palette — less peachy
         saturation, more amber, lower contrast. Aims for "cosy dim" rather
         than "bright daylight". */
      --wall: #d8b888;
      --wall-shade: #c2a070;
      --floor: #8c5e3a;
      --floor-shade: #6b4426;
      --outline: #3d2412;
      --cream: #ead0a2;
      --peach: #c89878;
      --coffee: #2d1a0c;
      --rosy: #c66e5a;
      --leaf: #6e8e6a;
      --sky-day: #a8bcc4;
      --sky-night: #2e3a5c;
      --gold: #c89858;
    }

    .cosy-room-app{
      min-height: 100vh;
      font-family: ui-rounded, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
      /* Calm warm cream instead of muddy dark amber so the actual room
         pops as the focal point. Subtle radial highlight from upper-left
         hints at where the light source is coming from. */
      background:
        radial-gradient(ellipse 80% 60% at 18% 0%, rgba(255, 232, 192, 0.95) 0%, rgba(245, 220, 178, 0) 60%),
        linear-gradient(180deg, #f3e6cb 0%, #e9d7b3 100%);
      color: #3d2412;
      padding: 24px;
    }

    .cosy-room-app .app{
      max-width: 1240px;
      margin: 0 auto;
      display: grid;
      grid-template-columns: minmax(0, 1fr) 380px;
      gap: 24px;
      align-items: start;
    }

    .cosy-room-app header.page-head{
      grid-column: 1 / -1;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 8px 4px 16px;
    }
    .cosy-room-app header.page-head h1{
      font-size: 22px;
      font-weight: 800;
      letter-spacing: -0.01em;
    }
    .cosy-room-app .coin-display{
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 6px 14px 6px 8px;
      background: linear-gradient(135deg, rgba(255,248,230,0.85), rgba(255,255,255,0.75));
      border: 1.5px solid rgba(184,134,11,0.25);
      border-radius: 999px;
      font-weight: 800;
      font-size: 17px;
      box-shadow: 0 2px 10px rgba(139,105,20,0.1), inset 0 1px 0 rgba(255,255,255,0.6);
    }
    .cosy-room-app .coin-svg{
      width: 26px; height: 26px;
      filter: drop-shadow(0 1px 2px rgba(139,105,20,0.35));
      flex-shrink: 0;
    }
    .cosy-room-app .coin-display .coin-count{
      color: #6b4c14;
      font-variant-numeric: tabular-nums;
      min-width: 2ch;
    }

    /* ─── Hunger / kibble display (sits beside coins) ─── */
    .cosy-room-app .head-displays{ display: inline-flex; gap: 10px; flex-wrap: wrap; }
    .cosy-room-app .hunger-display{
      display: inline-flex;
      align-items: center;
      gap: 8px;
      padding: 8px 14px;
      background: rgba(255, 255, 255, 0.7);
      border: 1px solid rgba(91, 53, 23, 0.18);
      border-radius: 999px;
      font-weight: 800;
      font-size: 14px;
      color: #5b3517;
      box-shadow: 0 4px 14px rgba(91, 53, 23, 0.06);
    }
    .cosy-room-app .kibble-icon{ width: 18px; height: 18px; }
    .cosy-room-app .hunger-bar{
      width: 72px;
      height: 8px;
      background: rgba(91, 53, 23, 0.22);
      border-radius: 4px;
      overflow: hidden;
      position: relative;
    }
    .cosy-room-app .hunger-fill{
      height: 100%;
      width: 100%;
      background: linear-gradient(90deg, #e89048, #c66e5a);
      border-radius: 4px;
      transition: width 0.5s ease-out, background 0.4s;
    }
    .cosy-room-app .hunger-fill.low{ background: linear-gradient(90deg, #c66e5a, #8b3a2a); }
    .cosy-room-app .hunger-fill.critical{ background: #6b2818; animation: cr-hunger-pulse 1.2s ease-in-out infinite; }
    @keyframes cr-hunger-pulse {
      0%, 100% { opacity: 1; }
      50% { opacity: 0.5; }
    }
    .cosy-room-app .feed-btn{
      background: rgba(91, 53, 23, 0.12);
      border: none;
      padding: 4px 12px;
      border-radius: 999px;
      font: inherit;
      font-size: 11.5px;
      font-weight: 800;
      color: #5b3517;
      cursor: pointer;
      transition: background 0.15s, transform 0.12s;
      letter-spacing: 0.02em;
    }
    .cosy-room-app .feed-btn:hover{ background: rgba(91, 53, 23, 0.22); transform: translateY(-1px); }
    .cosy-room-app .feed-btn:disabled{ opacity: 0.42; cursor: not-allowed; transform: none; }

    /* ─── Pet hunger moods ─── */
    .cosy-room-app .pet-actor.mood-hungry svg{ filter: saturate(0.7) brightness(0.92); }
    .cosy-room-app .pet-actor.mood-starving svg{ filter: grayscale(0.45) brightness(0.7); }
    .cosy-room-app .pet-actor.mood-starving{ animation: cr-pet-sad-bob 3.4s ease-in-out infinite; }
    @keyframes cr-pet-sad-bob {
      0%, 100% { transform: translateY(0); }
      50% { transform: translateY(3px); }
    }

    /* ─── Places counter + unlock badges ─── */
    .cosy-room-app .room-toolbar{
      position: absolute;
      top: 14px;
      left: 14px;
      right: 14px;
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      gap: 10px;
      z-index: 11;
      pointer-events: none;
    }
    .cosy-room-app .room-toolbar > *{ pointer-events: auto; }
    .cosy-room-app .places-counter{
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 6px 12px;
      background: rgba(255, 255, 255, 0.78);
      border: 1px solid rgba(91, 53, 23, 0.18);
      border-radius: 999px;
      font-size: 11.5px;
      font-weight: 800;
      color: #5b3517;
      letter-spacing: 0.02em;
      box-shadow: 0 4px 10px rgba(45, 26, 12, 0.12);
      cursor: help;
    }
    .cosy-room-app .places-counter .paw{ font-size: 12px; }
    .cosy-room-app .unlock-badge{
      display: inline-block;
      margin-top: 3px;
      padding: 2px 7px;
      background: linear-gradient(90deg, #e89048, #c66e5a);
      color: #fff7e8;
      border-radius: 999px;
      font-size: 9.5px;
      font-weight: 800;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      align-self: flex-start;
    }

    /* ─── Sound toggle (floating, bottom-left) ─── */
    .cosy-room-app .sound-toggle{
      position: fixed;
      bottom: 18px;
      left: 18px;
      width: 42px;
      height: 42px;
      border-radius: 50%;
      border: 1px solid rgba(91, 53, 23, 0.2);
      background: rgba(255, 255, 255, 0.85);
      cursor: pointer;
      box-shadow: 0 4px 14px rgba(45, 26, 12, 0.2);
      font-size: 17px;
      z-index: 60;
      transition: transform 0.12s, background 0.15s;
      backdrop-filter: blur(6px);
    }
    .cosy-room-app .sound-toggle:hover{ transform: scale(1.06); background: rgba(255, 255, 255, 0.95); }
    .cosy-room-app .sound-toggle.is-on{ background: #5b3517; color: #fde2c0; border-color: #5b3517; }

    /* ─── Drag handles ─── */
    .cosy-room-app .slot > *:hover{ cursor: grab; }
    .cosy-room-app .slot > *.is-dragging{
      cursor: grabbing;
      filter: drop-shadow(0 10px 18px rgba(45, 26, 12, 0.45)) brightness(1.04);
      transition: none !important;
      z-index: 25;
    }
    .cosy-room-app .slot.is-dragging{ z-index: 25; }
    .cosy-room-app .drag-hint{
      position: absolute;
      top: -22px;
      left: 50%;
      transform: translateX(-50%);
      padding: 2px 8px;
      background: rgba(45, 26, 12, 0.85);
      color: #fde2c0;
      border-radius: 999px;
      font-size: 10px;
      font-weight: 700;
      white-space: nowrap;
      pointer-events: none;
      opacity: 0;
      transition: opacity 0.18s;
    }
    .cosy-room-app .slot > *:hover .drag-hint, .cosy-room-app .slot > *.is-dragging .drag-hint{ opacity: 0.92; }

    /* ─────────────────────────────────────────────────────────
       ROOM STAGE
       ───────────────────────────────────────────────────────── */
    .cosy-room-app .room-stage{
      position: relative;
      aspect-ratio: 5 / 3.4;
      max-height: 640px;
      border-radius: 28px;
      overflow: hidden;
      background: var(--wall);
      /* Refined: softer ambient shadow + crisp inner highlight for a
         "framed diorama" feel instead of the previous heavy bottom drop. */
      box-shadow:
        0 24px 60px -10px rgba(45, 26, 12, 0.32),
        0 6px 16px rgba(45, 26, 12, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.22);
      border: 1px solid rgba(45, 26, 12, 0.18);
    }

    /* Corner-only vignette over the whole stage. Uses `multiply` so it
       only darkens — items in the corners read as "this part of the
       room is in shadow" rather than being washed out. The warm fill
       is intentionally NOT here — the wall and floor each carry their
       own lighting gradients so light bounces correctly off each
       surface (instead of one flat overlay muddying everything). */
    .cosy-room-app .room-stage::after{
      content: '';
      position: absolute;
      inset: 0;
      pointer-events: none;
      background:
        /* Cool corner shadow lower-right (away from the upper-left light) */
        radial-gradient(ellipse 60% 50% at 88% 95%, rgba(45, 26, 12, 0.55) 0%, rgba(45, 26, 12, 0) 60%),
        /* Soft outer vignette pulling focus toward center */
        radial-gradient(ellipse 115% 100% at 50% 45%, rgba(45, 26, 12, 0) 60%, rgba(45, 26, 12, 0.5) 100%);
      mix-blend-mode: multiply;
      z-index: 10;
    }

    .cosy-room-app .room-wall{
      position: absolute;
      inset: 0 0 32% 0;
      /* Fallback solid color in case `color-mix()` is unsupported. */
      background-color: var(--wall);
      /* Subtle vertical ambient gradient on the wall — top a shade warmer
         (catches sky/ceiling reflection), bottom slightly cooler/darker
         (ambient occlusion toward the floor seam). This is what makes the
         wall feel like a SURFACE instead of a flat color swatch. */
      background:
        linear-gradient(180deg,
          color-mix(in srgb, var(--wall) 92%, #fff7e6 8%) 0%,
          var(--wall) 45%,
          color-mix(in srgb, var(--wall) 92%, #5b3517 8%) 100%);
      transition: background 0.4s;
    }
    /* Paper-grain texture overlay on the wall — gives it actual surface
       quality. Uses inline SVG turbulence to avoid extra HTTP requests. */
    .cosy-room-app .room-wall::after{
      content: '';
      position: absolute;
      inset: 0;
      pointer-events: none;
      background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence baseFrequency='0.85' numOctaves='2' seed='3'/><feColorMatrix values='0 0 0 0 0.18  0 0 0 0 0.1  0 0 0 0 0.05  0 0 0 0.04 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
      opacity: 0.55;
      mix-blend-mode: multiply;
    }
    /* Upper-corner ambient darkening on the wall — fakes the way a ceiling
       cove darkens the very top of the wall. Subtle, but reads as "real". */
    .cosy-room-app .room-wall::before{
      content: '';
      position: absolute;
      inset: 0;
      pointer-events: none;
      background:
        radial-gradient(ellipse 60% 30% at 0% 0%,   rgba(45, 26, 12, 0.18) 0%, transparent 70%),
        radial-gradient(ellipse 60% 30% at 100% 0%, rgba(45, 26, 12, 0.18) 0%, transparent 70%);
    }

    /* ─── Wallpaper patterns ─── */
    .cosy-room-app .room-wall.wall-stripes-v{
      background:
        repeating-linear-gradient(90deg,
          var(--wall) 0, var(--wall) 24px,
          var(--wall-shade) 24px, var(--wall-shade) 26px);
    }
    .cosy-room-app .room-wall.wall-stripes-h{
      background:
        repeating-linear-gradient(0deg,
          var(--wall) 0, var(--wall) 26px,
          var(--wall-shade) 26px, var(--wall-shade) 28px);
    }
    .cosy-room-app .room-wall.wall-polka{
      background-color: var(--wall);
      background-image: radial-gradient(circle at 25px 25px, var(--wall-shade) 4px, transparent 5px);
      background-size: 50px 50px;
    }
    .cosy-room-app .room-wall.wall-floral{
      background-color: var(--wall);
      background-image:
        radial-gradient(ellipse 10px 5px at 30px 30px, rgba(198, 110, 90, 0.45) 50%, transparent 55%),
        radial-gradient(ellipse 5px 10px at 30px 30px, rgba(198, 110, 90, 0.45) 50%, transparent 55%),
        radial-gradient(circle 2px at 30px 30px, #c89858 50%, transparent 55%);
      background-size: 70px 70px;
    }
    .cosy-room-app .room-wall.wall-chevron{
      background-color: var(--wall);
      background-image:
        linear-gradient(135deg, var(--wall-shade) 25%, transparent 25%, transparent 75%, var(--wall-shade) 75%),
        linear-gradient(45deg, var(--wall-shade) 25%, transparent 25%, transparent 75%, var(--wall-shade) 75%);
      background-size: 32px 32px;
      background-position: 0 0, 16px 16px;
      background-blend-mode: multiply;
      opacity: 0.96;
    }
    .cosy-room-app .room-wall.wall-grid{
      background-color: var(--wall);
      background-image:
        linear-gradient(rgba(91, 53, 23, 0.18) 1px, transparent 1px),
        linear-gradient(90deg, rgba(91, 53, 23, 0.18) 1px, transparent 1px);
      background-size: 60px 60px;
    }
    .cosy-room-app .room-wall.wall-stars{
      background-color: var(--wall);
      background-image:
        radial-gradient(circle 1.5px at 12px 18px, #fde2c0 50%, transparent 55%),
        radial-gradient(circle 1px at 40px 8px, #fde2c0 50%, transparent 55%),
        radial-gradient(circle 1.5px at 28px 32px, #fde2c0 50%, transparent 55%),
        radial-gradient(circle 1px at 55px 25px, #fde2c0 50%, transparent 55%);
      background-size: 70px 50px;
    }
    /* legacy compatibility */
    .cosy-room-app .room-wall.is-striped{ background:
      repeating-linear-gradient(90deg, var(--wall) 0, var(--wall) 24px, var(--wall-shade) 24px, var(--wall-shade) 26px); }

    .cosy-room-app .room-floor{
      position: absolute;
      left: 0; right: 0; bottom: 0;
      height: 32%;
      /* Fallback solid color in case any of the gradient layers are
         unsupported (color-mix is CSS Color Level 4). */
      background-color: var(--floor);
      /* Wood-plank floor with three layered effects:
         1. Vertical gradient — recedes darker toward the back (top of floor)
         2. Plank repeating-gradient — varied widths for organic feel
         3. Subtle grain noise overlay applied via ::after */
      background:
        /* Plank seams — varied widths so it doesn't look like printed pattern */
        repeating-linear-gradient(90deg,
          rgba(45, 26, 12, 0.18) 0,
          rgba(45, 26, 12, 0.18) 1px,
          transparent 1px,
          transparent 84px,
          rgba(45, 26, 12, 0.12) 84px,
          rgba(45, 26, 12, 0.12) 85px,
          transparent 85px,
          transparent 152px),
        /* Soft horizontal grain bands suggesting wood texture */
        repeating-linear-gradient(180deg,
          transparent 0,
          transparent 12px,
          rgba(91, 53, 23, 0.04) 12px,
          rgba(91, 53, 23, 0.04) 13px),
        /* Floor depth gradient — back (top) darker, front (bottom) lit */
        linear-gradient(180deg,
          color-mix(in srgb, var(--floor-shade) 88%, #2d1a0c 12%) 0%,
          var(--floor) 30%,
          color-mix(in srgb, var(--floor) 90%, #f5ead3 10%) 65%,
          color-mix(in srgb, var(--floor) 88%, #5b3517 12%) 100%);
    }
    /* Soft warm light pool on the floor — comes from the upper-left
       (matches the wall lighting). Makes the room feel lamp-lit. */
    .cosy-room-app .room-floor::before{
      content: '';
      position: absolute;
      inset: 0;
      pointer-events: none;
      background:
        radial-gradient(ellipse 65% 110% at 35% 0%, rgba(255, 220, 160, 0.22) 0%, rgba(255, 220, 160, 0) 60%),
        radial-gradient(ellipse 80% 60% at 50% 100%, rgba(45, 26, 12, 0) 0%, rgba(45, 26, 12, 0.22) 100%);
    }
    /* Floor grain noise (subtle wood texture) */
    .cosy-room-app .room-floor::after{
      content: '';
      position: absolute;
      inset: 0;
      pointer-events: none;
      background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='wg'><feTurbulence baseFrequency='0.04 0.9' numOctaves='2' seed='7'/><feColorMatrix values='0 0 0 0 0.36  0 0 0 0 0.22  0 0 0 0 0.12  0 0 0 0.5 0'/></filter><rect width='100%25' height='100%25' filter='url(%23wg)'/></svg>");
      opacity: 0.18;
      mix-blend-mode: multiply;
    }

    /* Skirting board between wall and floor — proper architectural moulding
       with a top highlight, midtone, and bottom shadow. Reads as a real
       3D detail rather than the previous 8px brown stripe.
       NB: No explicit z-index — source order puts it ABOVE the wall and
       BELOW furniture slots, which is what we want (furniture sits in
       front of the trim). */
    .cosy-room-app .room-skirting{
      position: absolute;
      left: 0; right: 0;
      bottom: 32%;
      height: 14px;
      background:
        linear-gradient(180deg,
          #d8b888 0%,
          #c89858 35%,
          #a07238 70%,
          #6b4426 100%);
      box-shadow:
        /* Cast shadow onto the floor below */
        0 3px 8px -2px rgba(45, 26, 12, 0.45),
        /* Inner top highlight (top edge catches the light) */
        inset 0 1px 0 rgba(255, 240, 200, 0.7),
        /* Inner bottom dark line (where it meets the floor) */
        inset 0 -1px 0 rgba(45, 26, 12, 0.55);
      border-top: 1px solid rgba(45, 26, 12, 0.4);
    }

    /* Slot containers — each absolute-positioned in the room */
    .cosy-room-app .slot{
      position: absolute;
      display: flex;
      align-items: flex-end;
      justify-content: center;
      pointer-events: none;
    }

    .cosy-room-app .slot.empty::after{
      content: attr(data-empty-label);
      font-size: 11px;
      font-weight: 700;
      color: rgba(91, 53, 23, 0.35);
      letter-spacing: 0.06em;
      text-transform: uppercase;
      border: 1.5px dashed rgba(91, 53, 23, 0.22);
      border-radius: 10px;
      padding: 6px 14px;
      background: rgba(255, 255, 255, 0.32);
      pointer-events: none;
    }

    .cosy-room-app .slot-window{ top: 6%;   left: 14%; width: 24%; height: 30%; align-items: center; }
    .cosy-room-app .slot-art{ top: 14%;  left: 44%; width: 14%; height: 20%; align-items: center; }
    .cosy-room-app .slot-furn-left{ bottom: 32%; left: 4%;  width: 26%; height: 46%; }
    .cosy-room-app .slot-furn-right{ bottom: 32%; right: 4%; width: 26%; height: 46%; }
    .cosy-room-app .slot-rug{ bottom: 4%; left: 50%; transform: translateX(-50%); width: 56%; height: 12%; align-items: center; z-index: 1; }
    .cosy-room-app .slot-decor{ bottom: 32%; left: 32%; width: 18%; height: 18%; }
    .cosy-room-app .slot-decor-2{ bottom: 4%; left: 12%; width: 12%; height: 18%; z-index: 2; }
    .cosy-room-app .slot-decor-3{ bottom: 4%; right: 12%; width: 12%; height: 18%; z-index: 2; }
    .cosy-room-app .slot-pet{ bottom: 4%; left: 60%; width: 16%; height: 22%; z-index: 3; }
    .cosy-room-app .slot-ceiling{ top: 0;    left: 50%; transform: translateX(-50%); width: 40%; height: 22%; align-items: flex-start; }

    /* SVG art inside slots fills naturally */
    .cosy-room-app .slot svg{
      width: 100%;
      height: 100%;
      max-height: 100%;
      overflow: visible;
    }

    /* Subtle item-arrival animation */
    @keyframes cr-item-pop {
      0% { transform: scale(0.6) translateY(8px); opacity: 0; }
      70% { transform: scale(1.08) translateY(-3px); opacity: 1; }
      100% { transform: scale(1) translateY(0); opacity: 1; }
    }
    .cosy-room-app .slot > *{
      animation: cr-item-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    }

    /* ─────────────────────────────────────────────────────────
       PET ACTOR — free-floating element that can wander to spots
       ───────────────────────────────────────────────────────── */
    .cosy-room-app .pet-actor{
      position: absolute;
      left: 60%;
      bottom: 4%;
      width: 16%;
      height: 22%;
      pointer-events: auto;
      cursor: pointer;
      transition: left 1.4s cubic-bezier(0.45, 0, 0.2, 1),
                  bottom 1.4s cubic-bezier(0.45, 0, 0.2, 1),
                  width 1.4s cubic-bezier(0.45, 0, 0.2, 1),
                  transform 0.3s ease-out;
      transform-origin: 50% 95%;
      z-index: 3;
    }
    .cosy-room-app .pet-actor.empty{ display: none; }
    .cosy-room-app .pet-actor svg{ width: 100%; height: 100%; display: block; pointer-events: none; }
    /* Depth tints — tiny atmospheric darken at the back to sell the perspective */
    .cosy-room-app .pet-actor.depth-front{ filter: none; }
    .cosy-room-app .pet-actor.depth-mid{ filter: brightness(0.96) saturate(0.96); }
    .cosy-room-app .pet-actor.depth-back{ filter: brightness(0.9) saturate(0.92); }
    .cosy-room-app .pet-actor.is-clicked{ animation: cr-pet-bounce 0.55s cubic-bezier(0.34, 1.56, 0.64, 1); }
    .cosy-room-app .pet-actor:hover{ transform: translateY(-2px); }
    @keyframes cr-pet-bounce {
      0%   { transform: scale(1) translateY(0); }
      30%  { transform: scale(1.12) translateY(-10px) rotate(-3deg); }
      60%  { transform: scale(0.94) translateY(0) rotate(2deg); }
      100% { transform: scale(1) translateY(0) rotate(0); }
    }
    /* eye pupils — JS sets a transform="translate(x y)" attribute on these */
    .cosy-room-app .eye-pupil{ transition: transform 0.18s ease-out; }

    /* Speech bubble that pops from the pet */
    .cosy-room-app .pet-bubble{
      position: absolute;
      bottom: 100%;
      left: 50%;
      transform: translate(-50%, -8px);
      background: #fff;
      border: 2px solid var(--outline);
      border-radius: 14px;
      padding: 6px 12px;
      font-size: 11.5px;
      font-weight: 800;
      color: var(--outline);
      white-space: nowrap;
      box-shadow: 0 4px 12px rgba(45, 26, 12, 0.18);
      z-index: 12;
      pointer-events: none;
      animation: cr-bubble-in 0.32s cubic-bezier(0.34, 1.56, 0.64, 1) both,
                 cr-bubble-out 0.45s ease-out 2.6s forwards;
    }
    .cosy-room-app .pet-bubble::after{
      content: '';
      position: absolute;
      bottom: -7px;
      left: 50%;
      transform: translateX(-50%) rotate(45deg);
      width: 10px;
      height: 10px;
      background: #fff;
      border-right: 2px solid var(--outline);
      border-bottom: 2px solid var(--outline);
    }
    @keyframes cr-bubble-in {
      0%   { opacity: 0; transform: translate(-50%, 4px) scale(0.5); }
      100% { opacity: 1; transform: translate(-50%, -8px) scale(1); }
    }
    @keyframes cr-bubble-out {
      0%   { opacity: 1; transform: translate(-50%, -8px) scale(1); }
      100% { opacity: 0; transform: translate(-50%, -16px) scale(0.96); }
    }

    /* FX overlay — hosts floating hearts, sparkles, etc. */
    .cosy-room-app .fx-overlay{
      position: absolute;
      inset: 0;
      pointer-events: none;
      z-index: 15;
      overflow: hidden;
    }
    .cosy-room-app .fx-heart{
      position: absolute;
      font-size: 22px;
      line-height: 1;
      filter: drop-shadow(0 2px 3px rgba(45,26,12,0.25));
      animation: cr-heart-rise 1.6s ease-out forwards;
    }
    @keyframes cr-heart-rise {
      0%   { opacity: 0; transform: translate(0, 0) scale(0.4) rotate(0); }
      18%  { opacity: 1; transform: translate(var(--dx, 0), -14px) scale(1.1) rotate(-6deg); }
      80%  { opacity: 0.85; transform: translate(calc(var(--dx, 0) * 1.4), -70px) scale(1.25) rotate(8deg); }
      100% { opacity: 0; transform: translate(calc(var(--dx, 0) * 1.6), -100px) scale(0.9) rotate(0); }
    }
    .cosy-room-app .fx-sparkle{
      position: absolute;
      width: 8px; height: 8px;
      background:
        linear-gradient(45deg, transparent 45%, #fde2c0 45%, #fde2c0 55%, transparent 55%),
        linear-gradient(-45deg, transparent 45%, #fde2c0 45%, #fde2c0 55%, transparent 55%);
      animation: cr-sparkle 0.9s ease-out forwards;
    }
    @keyframes cr-sparkle {
      0%   { opacity: 0; transform: scale(0); }
      40%  { opacity: 1; transform: scale(1.2) rotate(40deg); }
      100% { opacity: 0; transform: scale(0.6) rotate(140deg); }
    }

    /* Pressable items — every slot's child gets pointer + bounce-on-click */
    .cosy-room-app .slot{
      pointer-events: none; /* slot wrapper doesn't catch clicks */
    }
    .cosy-room-app .slot > *{
      pointer-events: auto;
      cursor: pointer;
      transition: filter 0.15s ease;
    }
    .cosy-room-app .slot > *:hover{
      filter: brightness(1.06) drop-shadow(0 4px 6px rgba(45,26,12,0.25));
    }
    .cosy-room-app .slot > *.is-pressed{ animation: cr-item-press 0.42s cubic-bezier(0.34, 1.56, 0.64, 1); }
    @keyframes cr-item-press {
      0%   { transform: scale(1) translateY(0); }
      40%  { transform: scale(1.08) translateY(-4px); }
      70%  { transform: scale(0.97) translateY(0); }
      100% { transform: scale(1) translateY(0); }
    }

    /* (Mascot cup is now a purchasable item — its art lives inline in ITEMS) */

    /* ─────────────────────────────────────────────────────────
       SHOP SIDEBAR
       ───────────────────────────────────────────────────────── */
    .cosy-room-app .shop{
      background: rgba(255, 255, 255, 0.7);
      border: 1px solid rgba(91, 53, 23, 0.12);
      border-radius: 20px;
      padding: 18px;
      box-shadow: 0 8px 24px rgba(91, 53, 23, 0.06);
      backdrop-filter: blur(6px);
    }
    .cosy-room-app .shop h2{
      font-size: 16px;
      font-weight: 800;
      margin-bottom: 4px;
    }
    .cosy-room-app .shop .shop-sub{
      font-size: 12px;
      color: rgba(91, 53, 23, 0.7);
      font-weight: 600;
      margin-bottom: 14px;
    }
    .cosy-room-app .shop-tabs{
      display: flex;
      flex-wrap: wrap;
      gap: 4px;
      margin-bottom: 14px;
    }
    .cosy-room-app .shop-tab{
      padding: 5px 12px;
      border: 1px solid rgba(91, 53, 23, 0.18);
      background: rgba(255, 255, 255, 0.5);
      color: rgba(91, 53, 23, 0.7);
      border-radius: 999px;
      font: inherit;
      font-size: 11.5px;
      font-weight: 800;
      letter-spacing: 0.02em;
      cursor: pointer;
      transition: all 0.15s;
    }
    .cosy-room-app .shop-tab.is-active{
      background: #5b3517;
      color: #fde2c0;
      border-color: #5b3517;
    }
    .cosy-room-app .shop-items{
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 10px;
      max-height: 580px;
      overflow-y: auto;
      padding-right: 4px;
    }
    .cosy-room-app .shop-items::-webkit-scrollbar{ width: 6px; }
    .cosy-room-app .shop-items::-webkit-scrollbar-thumb{ background: rgba(91, 53, 23, 0.2); border-radius: 999px; }

    .cosy-room-app .item-card{
      display: flex;
      flex-direction: column;
      gap: 8px;
      padding: 10px;
      background: #fff;
      border: 1px solid rgba(91, 53, 23, 0.14);
      border-radius: 14px;
      cursor: pointer;
      transition: transform 0.12s, box-shadow 0.15s, border-color 0.15s;
    }
    .cosy-room-app .item-card:hover{
      transform: translateY(-1px);
      box-shadow: 0 6px 16px rgba(91, 53, 23, 0.1);
      border-color: rgba(91, 53, 23, 0.3);
    }
    .cosy-room-app .item-card.is-placed{
      border-color: #7ba87c;
      background: #f0f9f0;
    }
    .cosy-room-app .item-thumb{
      width: 100%;
      aspect-ratio: 1;
      background: linear-gradient(180deg, #fff7e8, #fde2c0);
      border-radius: 10px;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 8px;
    }
    .cosy-room-app .item-thumb svg{
      max-width: 80%;
      max-height: 80%;
    }
    .cosy-room-app .item-info{
      display: flex;
      flex-direction: column;
      gap: 2px;
    }
    .cosy-room-app .item-info strong{
      font-size: 12.5px;
      font-weight: 800;
      letter-spacing: -0.005em;
    }
    .cosy-room-app .item-info small{
      font-size: 11px;
      color: rgba(91, 53, 23, 0.65);
      font-weight: 600;
    }
    .cosy-room-app .item-buy{
      width: 100%;
      padding: 6px;
      border: none;
      border-radius: 8px;
      background: #5b3517;
      color: #fde2c0;
      font: inherit;
      font-size: 11.5px;
      font-weight: 800;
      letter-spacing: 0.02em;
      cursor: pointer;
      transition: background 0.15s;
    }
    .cosy-room-app .item-buy:hover{ background: #7a4a26; }
    .cosy-room-app .item-buy.is-owned{ background: #b8946a; }
    .cosy-room-app .item-buy.is-placed{ background: #7ba87c; }
    .cosy-room-app .item-buy:disabled{ opacity: 0.4; cursor: not-allowed; }

    .cosy-room-app .toast{
      position: fixed;
      bottom: 24px;
      left: 50%;
      transform: translateX(-50%) translateY(20px);
      padding: 10px 18px;
      background: #5b3517;
      color: #fde2c0;
      border-radius: 999px;
      font-size: 13px;
      font-weight: 700;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.2s, transform 0.2s;
      z-index: 999;
    }
    .cosy-room-app .toast.is-show{
      opacity: 1;
      transform: translateX(-50%) translateY(0);
    }

    .cosy-room-app .reset-btn{
      background: none;
      border: 1px solid rgba(91, 53, 23, 0.3);
      color: rgba(91, 53, 23, 0.7);
      padding: 6px 14px;
      border-radius: 999px;
      font: inherit;
      font-size: 11.5px;
      font-weight: 700;
      cursor: pointer;
      margin-top: 14px;
    }
    .cosy-room-app .reset-btn:hover{
      color: #5b3517;
      border-color: #5b3517;
    }

    @media (max-width: 900px) {
      .cosy-room-app .app{ grid-template-columns: 1fr; }
      .cosy-room-app .room-stage{ aspect-ratio: 5/3.4; }
    }

/* ─── Embedded-mode overrides (when mounted inside a tab) ─── */
.cosy-room-app {
  min-height: auto;
  padding: 0;
  background: transparent;
}
.cosy-room-app .app {
  max-width: 100%;
}
.cosy-room-app .page-head h1 {
  font-size: 22px;
  margin: 0;
}
/* Larger screens: keep the shop sidebar; smaller: stack */
@media (max-width: 1080px) {
  .cosy-room-app .app { grid-template-columns: 1fr; }
}
/* Stop the sound toggle and toast from being position:fixed when embedded —
   they'd float over the whole page. Anchor them to the cosy-room-app container. */
.cosy-room-app { position: relative; }
.cosy-room-app .sound-toggle {
  position: absolute;
  bottom: 14px;
  left: 14px;
}
.cosy-room-app .toast {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
}
.cosy-room-app .toast.is-show {
  transform: translateX(-50%) translateY(0);
}

/* ─── Cosy Reward Toast — shown on ANY tab when study earns coins ─── */
.cosy-reward-toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(16px) scale(0.95);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px 10px 12px;
  background: linear-gradient(135deg, #fff9e6, #fff4cc);
  border: 1.5px solid rgba(184, 134, 11, 0.3);
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(139, 105, 20, 0.18), 0 2px 6px rgba(0,0,0,0.06);
  font-family: ui-rounded, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-weight: 800;
  font-size: 15px;
  color: #6b4c14;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
}
.cosy-reward-toast.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}
.cosy-reward-toast .crt-coin {
  width: 24px; height: 24px;
  filter: drop-shadow(0 1px 2px rgba(139,105,20,0.3));
  flex-shrink: 0;
  animation: crt-bounce 0.5s ease 0.1s;
}
.cosy-reward-toast .crt-kibble {
  font-size: 12px;
  font-weight: 700;
  color: #8b6914;
  opacity: 0.8;
}
.cosy-reward-toast small {
  font-size: 11px;
  font-weight: 600;
  color: #9a7a30;
  margin-left: 4px;
}
@keyframes crt-bounce {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.35) rotate(-8deg); }
  70% { transform: scale(0.92); }
}
