    :root {
      --cream: #faf6f0;
      --blush: #f9d6d6;
      --mint: #c8e6d8;
      --butter: #fff2cc;
      --lavender: #e0d5f0;
      --oatmeal: #ebe4d8;
      --warm: #c4a484;
      --ink: #3a3a3a;
      --soft: #b8b0a4;
      --shadow: 0 2px 8px rgba(58, 58, 58, 0.08);
      --shadow-lg: 0 4px 16px rgba(58, 58, 58, 0.12);
    }
    * { box-sizing: border-box; }
    html, body {
      margin: 0; height: 100%;
      font-family: 'Quicksand', 'Nunito', 'Avenir Next', system-ui, sans-serif;
      background: var(--cream); color: var(--ink);
      overflow: hidden;
    }
    #screen-app {
      user-select: none;
      -webkit-user-select: none;
      -webkit-touch-callout: none;
    }
    #screen-landing,
    #screen-parents {
      user-select: text;
      -webkit-user-select: text;
    }

    /* Screen system */
    .screen { display: none; height: 100%; }
    .screen.active { display: flex; flex-direction: column; }

    /* ============ LANDING ============ */
    #screen-landing.active {
      align-items: center;
      justify-content: center;
      background:
        radial-gradient(circle at 50% 38%, rgba(255,255,255,0.85), rgba(255,255,255,0) 32%),
        linear-gradient(135deg, #fff5e6 0%, #e6f0e8 50%, #ece4f3 100%);
    }
    .landing-inner {
      text-align: center;
      padding: 40px 24px;
      max-width: 520px;
    }
    .landing-mascot {
      width: 150px;
      height: 150px;
      margin: 0 auto 18px;
      animation: bob 3s ease-in-out infinite;
      display: block;
    }
    .landing-mascot svg { width: 100%; height: 100%; display: block; }
    .logo-mascot {
      width: 28px; height: 28px;
      display: inline-block; vertical-align: middle;
      margin-right: 4px;
    }
    .logo-mascot svg { width: 100%; height: 100%; display: block; }
    @keyframes bob {
      0%, 100% { transform: translateY(0); }
      50% { transform: translateY(-8px); }
    }
    .landing-title {
      font-size: 38px;
      font-weight: 700;
      margin: 0 0 10px;
      letter-spacing: 0.3px;
    }
    .landing-tagline {
      font-size: 17px;
      color: var(--soft);
      margin: 0 0 32px;
      font-weight: 600;
    }
    .landing-buttons {
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      gap: 10px;
    }
    .landing-cta {
      font: inherit;
      font-size: 17px;
      font-weight: 700;
      padding: 14px 32px;
      background: var(--ink);
      color: #fff;
      border: none;
      border-radius: 999px;
      cursor: pointer;
      box-shadow: var(--shadow-lg);
      transition: transform 0.1s, box-shadow 0.2s;
    }
    .landing-cta:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.18); }
    .landing-secondary {
      font: inherit;
      font-size: 15px;
      font-weight: 600;
      padding: 14px 24px;
      background: rgba(255,255,255,0.7);
      color: var(--ink);
      border: none;
      border-radius: 999px;
      cursor: pointer;
      transition: background 0.2s;
    }
    .landing-secondary:hover { background: #fff; }
    .landing-trust {
      margin-top: 36px;
      font-size: 13px;
      color: var(--soft);
      font-weight: 600;
      letter-spacing: 0.3px;
    }

    /* ============ PARENTS ============ */
    #screen-parents.active {
      background: var(--cream);
      overflow-y: auto;
      display: block;
    }
    .parents-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 14px 24px;
      background: #fff;
      box-shadow: var(--shadow);
      position: sticky;
      top: 0;
      z-index: 5;
    }
    .parents-header .logo { font-weight: 700; font-size: 18px; }
    .parents-content {
      max-width: 760px;
      margin: 32px auto 60px;
      padding: 0 24px;
    }
    .parents-intro {
      text-align: center;
      margin-bottom: 32px;
    }
    .parents-intro h1 {
      font-size: 32px;
      margin: 0 0 8px;
    }
    .parents-intro p {
      font-size: 16px;
      color: var(--soft);
      margin: 0;
      font-weight: 600;
    }
    .parents-card {
      background: #fff;
      border-radius: 18px;
      padding: 26px 28px;
      margin-bottom: 18px;
      box-shadow: var(--shadow);
    }
    .parents-card h2 {
      margin: 0 0 12px;
      color: var(--ink);
      font-size: 19px;
    }
    .parents-card p, .parents-card li {
      color: var(--ink);
      line-height: 1.65;
      font-size: 15px;
    }
    .parents-card p:not(:last-child) { margin-bottom: 10px; }
    .parents-card ul { padding-left: 20px; margin: 0; }
    .parents-card li { margin-bottom: 8px; }
    .parents-card.green { background: #f3faf5; border-left: 4px solid #8fc59d; }
    .parents-card.amber { background: #fffaee; border-left: 4px solid #d4a85e; }
    .parents-footer {
      text-align: center;
      color: var(--soft);
      font-size: 13px;
      margin-top: 32px;
    }

    /* ============ APP ============ */
    header {
      display: flex; align-items: center; justify-content: space-between;
      padding: 14px 24px;
      background: #fff; box-shadow: var(--shadow);
      z-index: 10; flex-shrink: 0;
    }
    .logo-area { display: flex; align-items: baseline; gap: 14px; }
    .logo { font-weight: 700; font-size: 20px; letter-spacing: 0.3px; }
    .logo .heart { color: #e89797; }
    .parents-link {
      font-size: 13px;
      color: var(--soft);
      font-weight: 600;
      cursor: pointer;
      padding: 4px 10px;
      border-radius: 999px;
      transition: background 0.2s, color 0.2s;
    }
    .parents-link:hover { background: var(--cream); color: var(--ink); }
    .mode-toggle { display: flex; background: var(--oatmeal); border-radius: 999px; padding: 4px; }
    .mode-toggle button {
      border: none; background: transparent;
      padding: 8px 22px; border-radius: 999px;
      font: inherit; font-weight: 600;
      color: var(--soft); cursor: pointer; transition: all 0.2s;
    }
    .mode-toggle button.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
    .top-actions { display: flex; gap: 8px; align-items: center; }
    .btn {
      border: none; background: #fff;
      padding: 10px 18px; border-radius: 999px;
      font: inherit; font-weight: 600; color: var(--ink);
      cursor: pointer; box-shadow: var(--shadow);
      transition: transform 0.1s, box-shadow 0.2s;
    }
    .btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
    .btn:active { transform: translateY(0); }
    .btn:disabled { opacity: 0.4; cursor: not-allowed; }
    .btn.primary { background: var(--ink); color: #fff; }
    .btn-small { padding: 6px 12px; font-size: 13px; }

    main { flex: 1; display: flex; overflow: hidden; }

    .tray {
      width: 240px; background: #fff;
      padding: 20px 16px; box-shadow: var(--shadow);
      overflow-y: auto; flex-shrink: 0; z-index: 5;
    }
    .tray h3 {
      margin: 0 0 10px; font-size: 12px;
      letter-spacing: 0.8px; text-transform: uppercase;
      color: var(--soft); font-weight: 700;
    }
    .tray h3:not(:first-of-type) { margin-top: 22px; }
    .tray-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
    .tray-item {
      aspect-ratio: 1; background: var(--cream); border-radius: 12px;
      display: flex; align-items: center; justify-content: center;
      font-size: 22px; cursor: grab;
      transition: transform 0.15s, background 0.2s; touch-action: none;
    }
    .tray-item:hover { background: var(--oatmeal); transform: scale(1.05); }
    .tray-item:active { cursor: grabbing; }
    .tray-add {
      width: 100%; padding: 12px; background: var(--mint);
      border: none; border-radius: 14px;
      font: inherit; font-weight: 600; cursor: pointer;
      margin-bottom: 8px; transition: transform 0.1s;
    }
    .tray-add:hover { transform: translateY(-1px); }
    .tray-add.pet { background: var(--lavender); }

    .room-picker { margin-bottom: 12px; }
    .room-picker-label { font-size: 12px; font-weight: 600; color: var(--ink); margin-bottom: 5px; }
    .room-picker-swatches { display: flex; gap: 5px; }
    .room-swatch {
      width: 24px; height: 24px;
      border: 2px solid #e8e6df;
      border-radius: 50%;
      cursor: pointer; padding: 0;
      transition: transform 0.1s, border-color 0.15s;
    }
    .room-swatch:hover { transform: scale(1.15); }
    .room-swatch.active { border-color: var(--ink); transform: scale(1.1); }

    .stage { flex: 1; position: relative; overflow: hidden; background: var(--cream); }
    .house {
      position: absolute; inset: 30px;
      background: var(--oatmeal); border-radius: 28px;
      box-shadow: inset 0 0 0 4px #fff, var(--shadow-lg);
      overflow: hidden;
    }
    .house-grid {
      position: absolute; inset: 20px;
      border-radius: 18px;
      background-color: #fff;
      overflow: hidden;
    }
    .room {
      position: absolute;
      box-shadow: inset 0 0 0 2px rgba(255,255,255,0.7);
      transition: background-color 0.3s;
    }
    .room-label {
      position: absolute;
      top: 10px; left: 14px;
      font-size: 11px; font-weight: 700;
      color: var(--ink); opacity: 0.4;
      letter-spacing: 0.5px; text-transform: uppercase;
      pointer-events: none;
    }

    .placed {
      position: absolute; cursor: grab;
      transform-origin: center center;
      transition: filter 0.15s; touch-action: none;
    }
    .placed.dragging { cursor: grabbing; opacity: 0.85; }
    .placed-furn {
      width: 60px; height: 60px;
      display: flex; align-items: center; justify-content: center;
      font-size: 36px;
      background: rgba(255,255,255,0.5); border-radius: 14px;
    }
    .placed-char, .placed-pet { width: 64px; height: 64px; }
    .placed-inner { width: 100%; height: 100%; transform-origin: center center; }
    .placed-char svg, .placed-pet svg { display: block; }
    .placed-motion-dance { animation: pose-dance 0.55s ease-in-out infinite; }
    .placed-motion-jump { animation: pose-jump 0.45s ease-in-out 3; }
    .placed-motion-bounce { animation: pose-bounce 0.4s ease-in-out infinite; }
    @keyframes pose-dance {
      0%, 100% { transform: translateY(0) rotate(0deg); }
      50% { transform: translateY(-4px) rotate(6deg); }
    }
    @keyframes pose-jump {
      0%, 100% { transform: translateY(0); }
      50% { transform: translateY(-10px); }
    }
    @keyframes pose-bounce {
      0%, 100% { transform: translateY(0); }
      50% { transform: translateY(-6px); }
    }
    body.play-mode .placed { cursor: pointer; }
    body.play-mode .placed-furn { cursor: default; }
    body.play-mode .tray { display: none; }

    .selection-ring {
      position: absolute; pointer-events: none;
      border-radius: 4px;
      outline: 3px dashed var(--ink); outline-offset: 6px;
      z-index: 400;
      transform-origin: center center;
      transition: opacity 0.12s;
    }
    body.is-dragging .selection-ring { opacity: 0; }
    body.play-mode .selection-ring { display: none; }

    .selection-toolbar {
      position: fixed; bottom: 24px; left: 50%;
      transform: translateX(-50%); background: #fff;
      border-radius: 999px; padding: 8px;
      box-shadow: var(--shadow-lg);
      display: none; align-items: center; gap: 4px;
      z-index: 500; animation: pop2 0.2s ease-out;
    }
    .selection-toolbar.show { display: flex; }
    body.play-mode .selection-toolbar { display: none !important; }
    .tool-name { padding: 0 14px; font-weight: 700; font-size: 14px; color: var(--ink); white-space: nowrap; }
    .tool-divider { width: 1px; height: 28px; background: var(--oatmeal); margin: 0 4px; }
    .tool-btn {
      border: none; background: var(--cream);
      width: 42px; height: 42px; border-radius: 50%;
      cursor: pointer; font-size: 18px;
      display: flex; align-items: center; justify-content: center;
      transition: background 0.15s, transform 0.1s;
      padding: 0; color: var(--ink);
    }
    .tool-btn:hover:not(:disabled) { background: var(--mint); transform: scale(1.08); }
    .tool-btn.danger:hover:not(:disabled) { background: var(--blush); }
    .tool-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; background: var(--cream); }

    .action-popover {
      position: fixed; background: #fff;
      border-radius: 16px; padding: 12px;
      box-shadow: var(--shadow-lg); z-index: 200;
      animation: pop2 0.2s ease-out;
      touch-action: manipulation;
    }
    @keyframes pop2 {
      from { transform: scale(0.85); opacity: 0; }
      to { transform: scale(1); opacity: 1; }
    }
    .action-popover .name { font-weight: 700; margin-bottom: 4px; text-align: center; font-size: 14px; }
    .action-popover .tags { text-align: center; font-size: 11px; color: var(--soft); margin-bottom: 8px; font-weight: 600; letter-spacing: 0.3px; }
    .action-popover .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; max-width: 240px; }
    .action-chip {
      background: var(--cream); border: none;
      padding: 10px 14px; border-radius: 999px;
      font: inherit; font-size: 13px; font-weight: 600;
      cursor: pointer; transition: background 0.2s;
      min-height: 44px;
      touch-action: manipulation;
      -webkit-tap-highlight-color: transparent;
    }
    .action-chip:hover { background: var(--mint); }
    .action-popover .shared-label {
      text-align: center; font-size: 10px; font-weight: 700;
      color: var(--soft); margin: 6px 0 4px; letter-spacing: 0.2px;
    }
    .action-chip-shared { background: var(--lavender, #ece4f3); }
    .action-chip-shared:hover { background: var(--mint); }

    .bubble {
      position: absolute; background: #fff;
      padding: 6px 12px; border-radius: 14px;
      font-size: 13px; font-weight: 600;
      box-shadow: var(--shadow);
      pointer-events: none; animation: bubblein 0.3s ease-out;
      white-space: nowrap; z-index: 150;
    }
    .bubble-pair {
      background: #fff8f0;
      border: 2px solid var(--mint, #c8e6d8);
      font-size: 14px;
    }
    @keyframes bubblein {
      from { transform: translateY(8px); opacity: 0; }
      to { transform: translateY(0); opacity: 1; }
    }

    .modal-overlay {
      position: fixed; inset: 0;
      background: rgba(58, 58, 58, 0.4);
      display: none; align-items: center; justify-content: center;
      z-index: 1000; animation: fade 0.2s;
    }
    .modal-overlay.open { display: flex; }
    @keyframes fade { from { opacity: 0; } to { opacity: 1; } }
    .modal {
      background: #fff; border-radius: 24px; padding: 28px;
      width: 600px; max-width: calc(100% - 32px);
      max-height: calc(100% - 32px); overflow-y: auto;
      box-shadow: var(--shadow-lg);
    }
    .modal h2 { margin: 0 0 6px; font-size: 22px; }
    .modal p.sub { margin: 0 0 20px; color: var(--soft); font-size: 14px; }
    .modal-row { display: flex; gap: 24px; align-items: flex-start; }
    .preview-box {
      width: 180px; height: 200px; background: var(--cream);
      border-radius: 18px;
      display: flex; align-items: center; justify-content: center; flex-shrink: 0;
      position: sticky; top: 0;
    }
    .controls { flex: 1; min-width: 0; }
    .control-group { margin-bottom: 16px; }
    .control-label {
      font-size: 12px; font-weight: 700; letter-spacing: 0.5px;
      text-transform: uppercase; color: var(--soft); margin-bottom: 8px;
    }
    .swatches { display: flex; flex-wrap: wrap; gap: 8px; }
    .swatch {
      width: 36px; height: 36px; border-radius: 50%;
      cursor: pointer; border: 3px solid transparent;
      transition: transform 0.1s, border-color 0.2s;
    }
    .swatch:hover { transform: scale(1.1); }
    .swatch.selected { border-color: var(--ink); }
    .name-input {
      width: 100%;
      padding: 10px 14px;
      border: 2px solid var(--oatmeal);
      border-radius: 12px;
      font: inherit; font-size: 14px;
      background: var(--cream); color: var(--ink);
      outline: none;
      transition: border-color 0.15s, background 0.15s;
      margin-bottom: 8px;
    }
    .name-input:focus { border-color: var(--ink); background: #fff; }
    .name-input.invalid { border-color: #c84a4a; background: #fde6e6; }
    .chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
    .name-chip {
      background: var(--cream); border: 2px solid transparent;
      padding: 8px 14px; border-radius: 999px;
      font: inherit; font-size: 14px; font-weight: 600;
      cursor: pointer; transition: all 0.15s;
    }
    .name-chip:hover { background: var(--oatmeal); }
    .name-chip.selected { background: var(--mint); border-color: var(--ink); }
    .name-chip:disabled { opacity: 0.4; cursor: not-allowed; }
    .modal-footer {
      display: flex; justify-content: flex-end; gap: 10px;
      margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--oatmeal);
    }

    .save-status {
      display: inline-flex; align-items: center; gap: 4px;
      font-size: 13px; font-weight: 600;
      padding: 6px 14px; border-radius: 999px;
      background: #e8f3e8; color: #5a8a5a;
      transition: background 0.25s, color 0.25s;
      white-space: nowrap;
    }
    .save-status.saving { background: #fff4d6; color: #8a6a2a; }
    .save-status.error  { background: #fde6e6; color: #c84a4a; }

    .toast {
      position: fixed; bottom: 90px; left: 50%;
      transform: translateX(-50%);
      background: var(--ink); color: #fff;
      padding: 12px 24px; border-radius: 999px;
      font-weight: 600; box-shadow: var(--shadow-lg);
      opacity: 0; transition: opacity 0.3s, transform 0.3s;
      pointer-events: none; z-index: 2000;
    }
    .toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

    .hint {
      position: absolute; top: 16px; left: 50%;
      transform: translateX(-50%);
      background: rgba(255,255,255,0.9);
      padding: 8px 16px; border-radius: 999px;
      font-size: 13px; color: var(--soft); font-weight: 600;
      pointer-events: none; box-shadow: var(--shadow);
      z-index: 12;
      max-width: 90%;
      text-align: center;
    }

    .story-banner {
      position: absolute; bottom: 52px; left: 50%;
      transform: translateX(-50%);
      display: none; align-items: center; gap: 8px;
      background: rgba(255, 255, 255, 0.95);
      padding: 10px 14px; border-radius: 16px;
      box-shadow: var(--shadow-lg);
      max-width: min(420px, 92%);
      z-index: 14;
      border: 2px solid var(--mint);
    }
    .story-banner.show { display: flex; }
    .story-emoji { font-size: 18px; flex-shrink: 0; }
    .story-text { font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.35; flex: 1; }
    .story-dismiss {
      border: none; background: var(--cream);
      width: 28px; height: 28px; border-radius: 50%;
      cursor: pointer; font-size: 12px; flex-shrink: 0;
    }
    .story-dismiss:hover { background: var(--oatmeal); }
    body.play-mode .story-banner.show { animation: pop2 0.25s ease-out; }

    body.play-mode .room-label.room-label-play {
      pointer-events: auto;
      cursor: pointer;
      opacity: 0.7;
      transition: opacity 0.15s;
    }
    body.play-mode .room-label.room-label-play:hover { opacity: 1; }

    .room-mood-overlay {
      position: absolute; inset: 0;
      pointer-events: none;
      transition: opacity 0.35s;
    }
    .room-mood-overlay.mood-cozy {
      background: linear-gradient(160deg, rgba(255, 220, 180, 0.35), rgba(255, 245, 230, 0.1));
    }
    .room-mood-overlay.mood-sunny {
      background: radial-gradient(circle at 30% 20%, rgba(255, 240, 120, 0.35), transparent 65%);
    }
    .room-mood-overlay.mood-night {
      background: rgba(35, 45, 85, 0.38);
    }
    .room-mood-overlay.mood-night::after {
      content: '✦ ✦ ✦';
      position: absolute; top: 18%; right: 12%;
      font-size: 10px; color: rgba(255, 255, 255, 0.55);
      letter-spacing: 6px;
    }

    .landing-continue {
      background: var(--lavender);
      margin-top: 4px;
    }
    .landing-continue:hover { filter: brightness(0.98); }

    .tutorial-overlay {
      position: fixed; inset: 0;
      background: rgba(58, 58, 58, 0.45);
      display: flex; align-items: flex-end; justify-content: center;
      padding: 24px; z-index: 3000;
    }
    .tutorial-card {
      background: #fff; border-radius: 20px;
      padding: 22px 24px; max-width: 400px; width: 100%;
      box-shadow: var(--shadow-lg);
      animation: pop2 0.25s ease-out;
    }
    .tutorial-step {
      font-size: 11px; font-weight: 700;
      color: var(--soft); text-transform: uppercase;
      letter-spacing: 0.5px; margin-bottom: 6px;
    }
    .tutorial-card h3 { margin: 0 0 8px; font-size: 20px; }
    .tutorial-card p { margin: 0 0 16px; color: var(--soft); line-height: 1.45; }
    .tutorial-actions { display: flex; gap: 10px; justify-content: flex-end; }
    .tutorial-highlight {
      position: relative; z-index: 3001;
      box-shadow: 0 0 0 4px var(--mint), var(--shadow-lg);
      border-radius: 16px;
    }

    .tray-backdrop { display: none; }
    .tray-toggle { display: none; }

    .btn, .tool-btn, .mode-toggle button, .tray-add, .tray-item, .tray-toggle, .story-dismiss {
      touch-action: manipulation;
      -webkit-tap-highlight-color: transparent;
    }

    /* ============ MOBILE / TOUCH ============ */
    @media (max-width: 768px) {
      #screen-app.active {
        height: calc(var(--app-vh, 1vh) * 100);
        max-height: -webkit-fill-available;
      }

      header {
        flex-wrap: wrap;
        padding: 10px 12px;
        padding-top: max(10px, env(safe-area-inset-top));
        gap: 8px;
      }
      .logo-area {
        flex: 1 1 100%;
        justify-content: space-between;
        align-items: center;
      }
      .logo { font-size: 17px; }
      .parents-link {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        padding: 8px 14px;
      }
      .mode-toggle {
        flex: 1;
        justify-content: center;
      }
      .mode-toggle button {
        flex: 1;
        min-height: 44px;
        padding: 10px 14px;
        font-size: 14px;
      }
      .top-actions {
        flex: 1;
        justify-content: flex-end;
        flex-wrap: wrap;
        gap: 6px;
      }
      .top-actions .btn-small {
        min-width: 44px;
        min-height: 44px;
        padding: 10px 12px;
        font-size: 15px;
      }
      .top-actions #export-btn,
      .top-actions #reset-btn {
        font-size: 0;
        min-width: 44px;
      }
      .top-actions #export-btn::after { content: '📷'; font-size: 18px; }
      .top-actions #reset-btn::after { content: '↺'; font-size: 18px; }
      .save-status {
        min-width: 44px;
        min-height: 44px;
        padding: 0 12px;
        justify-content: center;
      }
      .save-status .save-label { display: none; }
      .save-status.saved::before { content: '✓'; font-size: 16px; }
      .save-status.saving::before { content: '···'; font-size: 14px; letter-spacing: 1px; }
      .save-status.error::before { content: '⚠'; font-size: 16px; }

      main {
        flex-direction: column;
        position: relative;
      }

      .stage {
        flex: 1;
        min-height: 0;
        order: 1;
      }

      .house {
        inset: 10px;
        border-radius: 20px;
      }
      .house-grid {
        inset: 8px;
        border-radius: 14px;
      }

      .hint {
        top: 10px;
        font-size: 12px;
        padding: 8px 12px;
        max-width: 94%;
      }

      .story-banner {
        bottom: max(12px, env(safe-area-inset-bottom));
        max-width: calc(100% - 20px);
        padding: 12px 14px;
      }
      .story-dismiss {
        width: 40px;
        height: 40px;
        font-size: 14px;
      }

      .tray-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(58, 58, 58, 0.4);
        z-index: 550;
      }
      body.tray-open .tray-backdrop { display: block; }

      .tray {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-height: min(52vh, 400px);
        transform: translateY(100%);
        transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
        border-radius: 20px 20px 0 0;
        z-index: 600;
        box-shadow: 0 -8px 28px rgba(58, 58, 58, 0.15);
        padding-bottom: max(16px, env(safe-area-inset-bottom));
        -webkit-overflow-scrolling: touch;
      }
      body.tray-open .tray { transform: translateY(0); }
      body.play-mode .tray { display: none !important; }

      .tray-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        left: max(14px, env(safe-area-inset-left));
        bottom: max(16px, env(safe-area-inset-bottom));
        width: 52px;
        height: 52px;
        border: none;
        border-radius: 50%;
        background: var(--ink);
        color: #fff;
        font-size: 22px;
        box-shadow: var(--shadow-lg);
        z-index: 520;
        cursor: pointer;
      }
      body.tray-open .tray-toggle { bottom: min(52vh, 400px); margin-bottom: 12px; }
      body.toolbar-visible .tray-toggle { bottom: calc(88px + env(safe-area-inset-bottom)); }
      body.play-mode .tray-toggle { display: none !important; }

      .tray-grid { grid-template-columns: repeat(5, 1fr); gap: 8px; }
      .tray-item {
        font-size: 26px;
        min-height: 48px;
        border-radius: 14px;
      }
      .tray-add {
        min-height: 48px;
        padding: 14px;
        font-size: 15px;
      }
      .room-swatch {
        width: 36px;
        height: 36px;
      }

      .selection-toolbar {
        left: max(8px, env(safe-area-inset-left));
        right: max(8px, env(safe-area-inset-right));
        transform: none;
        width: auto;
        max-width: none;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        padding: 10px 12px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        bottom: max(12px, env(safe-area-inset-bottom));
        border-radius: 20px;
        gap: 6px;
        scrollbar-width: none;
      }
      .selection-toolbar::-webkit-scrollbar { display: none; }
      .selection-toolbar .tool-name { display: none; }
      .selection-toolbar .tool-divider { height: 36px; margin: 0 2px; }
      .tool-btn {
        width: 48px;
        height: 48px;
        font-size: 20px;
        flex-shrink: 0;
      }

      .action-popover {
        padding: 14px;
        max-width: calc(100vw - 20px) !important;
      }
      .action-popover .actions { max-width: none; gap: 8px; }
      .action-chip { font-size: 14px; padding: 12px 16px; }

      body.play-mode .room-label.room-label-play {
        font-size: 12px;
        padding: 8px 12px;
        min-height: 36px;
        display: inline-flex;
        align-items: center;
        top: 6px;
        left: 8px;
        background: rgba(255, 255, 255, 0.55);
        border-radius: 999px;
      }

      .placed-furn { width: 56px; height: 56px; font-size: 32px; }
      .placed-char, .placed-pet { width: 58px; height: 58px; }

      .modal { padding: 20px 18px; border-radius: 20px; }
      .modal-row { flex-direction: column; align-items: center; }
      .preview-box {
        width: 100%;
        max-width: 200px;
        height: 160px;
        position: static;
      }
      .name-chip { min-height: 44px; padding: 10px 16px; }
      .swatch { width: 44px; height: 44px; }

      .toast {
        bottom: max(100px, calc(80px + env(safe-area-inset-bottom)));
      }
      body.toolbar-visible .toast { bottom: max(160px, calc(140px + env(safe-area-inset-bottom))); }

      .landing-cta, .landing-secondary {
        min-height: 48px;
        width: 100%;
        max-width: 280px;
      }
      .landing-title { font-size: 30px; }

      .tutorial-overlay {
        padding: 16px;
        padding-bottom: max(16px, env(safe-area-inset-bottom));
      }
      .tutorial-actions .btn { min-height: 44px; }
    }

    @media (max-width: 380px) {
      .top-actions #undo-btn { font-size: 0; min-width: 44px; }
      .top-actions #undo-btn::after { content: '↶'; font-size: 18px; }
    }
