/* CREATE — the app shell: home, editor frame, stage, tree, inspector, sheets.
   Tokens live on :root; code.css / art.css / publish.css (other helpers) use them too. */

@font-face { font-family: "CreateDisplay"; src: url(/fonts/bungee.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "CreateHead"; src: url(/fonts/bricolage.woff2) format("woff2"); font-weight: 400 800; font-display: swap; }
@font-face { font-family: "CreateBody"; src: url(/fonts/worksans.woff2) format("woff2"); font-weight: 400 700; font-display: swap; }
/* the engine draws game text with these names: same files */
@font-face { font-family: "Work Sans"; src: url(/fonts/worksans.woff2) format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Bricolage Grotesque"; src: url(/fonts/bricolage.woff2) format("woff2"); font-weight: 400 800; font-display: swap; }
@font-face { font-family: "Bungee"; src: url(/fonts/bungee.woff2) format("woff2"); font-display: swap; }

:root {
  --bg: #0a0810; --bg-2: #110e19; --card: #16131f; --card-2: #1d1929; --card-3: #252034;
  --ink: #f6f2ea; --soft: #b0aabd; --dim: #7c768b; --line: rgba(255,255,255,.09); --line-2: rgba(255,255,255,.16);
  --hot: #ff5b3d; --hot-2: #ff7a5c; --hot-ink: #1a0d08; --gold: #ffb53d;
  --cat-events: #ffb53d; --cat-motion: #3bb8f5; --cat-physics: #2ec4b6; --cat-looks: #a98bff;
  --cat-ui: #f06bb5; --cat-making: #33d17a; --cat-game: #ff5b3d; --cat-numbers: #22d3ee;
  --sel: #ffb53d; --focus: #ffb53d;
  --r-sm: 10px; --r: 14px; --r-lg: 18px;
  --font-display: "CreateDisplay", "CreateHead", system-ui, sans-serif;
  --font-head: "CreateHead", "CreateBody", system-ui, sans-serif;
  --font-body: "CreateBody", system-ui, -apple-system, "Segoe UI", sans-serif;
  --shadow: 0 10px 30px rgba(0,0,0,.45), 0 2px 6px rgba(0,0,0,.35);
  --top-h: 56px; --tabs-h: 60px;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body { font: 400 16px/1.45 var(--font-body); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-family: var(--font-head); margin: 0; letter-spacing: -.01em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
::selection { background: rgba(255,91,61,.4); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- icons + buttons ---------- */
.ico { display: inline-grid; place-items: center; width: 22px; height: 22px; flex: none; }
.ico svg { width: 100%; height: 100%; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border-radius: var(--r); border: 1px solid var(--line-2); background: var(--card-2); color: var(--ink);
  font-weight: 600; font-size: 15px; white-space: nowrap; transition: background .15s, transform .1s, border-color .15s; user-select: none; }
.btn:hover:not(:disabled) { background: var(--card-3); border-color: rgba(255,255,255,.24); }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.98); }
.btn:disabled { opacity: .38; cursor: default; }
.btn.round { width: 44px; padding: 0; border-radius: 50%; }
.btn.square { width: 44px; padding: 0; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover:not(:disabled) { background: rgba(255,255,255,.07); }
.btn.primary { background: var(--hot); border-color: transparent; color: var(--hot-ink); }
.btn.primary:hover:not(:disabled) { background: var(--hot-2); }
.btn.gold { background: var(--gold); border-color: transparent; color: #1f1405; }
.btn.danger { background: #3a1416; border-color: rgba(255,91,91,.45); color: #ffb4ad; }
.btn.danger:hover:not(:disabled) { background: #4c191c; }
.btn.on { background: rgba(255,181,61,.16); border-color: rgba(255,181,61,.55); color: var(--gold); }
.btn.play { background: var(--hot); color: var(--hot-ink); border-color: transparent; font-family: var(--font-head); font-weight: 800; letter-spacing: .02em; padding: 0 18px 0 14px; }
.btn.play:hover { background: var(--hot-2); }

.field { width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--r-sm); border: 1px solid var(--line-2);
  background: var(--bg-2); color: var(--ink); font-size: 16px; }
.field:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255,181,61,.2); }
select.field { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--soft) 50%), linear-gradient(135deg, var(--soft) 50%, transparent 50%);
  background-position: calc(100% - 18px) 19px, calc(100% - 13px) 19px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }

/* ---------- toast ---------- */
#toast { position: fixed; left: 50%; bottom: calc(84px + var(--sab)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #241f33; border: 1px solid var(--line-2); color: var(--ink); padding: 11px 16px; border-radius: 12px; font-weight: 600; font-size: 15px;
  box-shadow: var(--shadow); transition: opacity .2s, transform .2s; z-index: 200; max-width: calc(100% - 32px); text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { border-color: rgba(255,91,61,.6); }

/* ---------- sheets (bottom on phones, centred cards on big screens) ---------- */
.sheet { position: fixed; inset: 0; z-index: 100; background: rgba(5,4,10,.62); display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn .16s ease both; backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.sheet.closing { animation: fadeOut .16s ease both; }
.sheet-card { width: 100%; max-height: calc(100% - 40px - var(--sat)); display: flex; flex-direction: column; background: var(--card);
  border: 1px solid var(--line-2); border-bottom: 0; border-radius: 22px 22px 0 0; box-shadow: var(--shadow); padding-bottom: var(--sab);
  animation: slideUp .2s cubic-bezier(.2,.9,.3,1.1) both; }
.sheet.closing .sheet-card { animation: slideDown .16s ease both; }
.sheet-card:focus { outline: none; }
.sheet-grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 9px auto 2px; flex: none; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 20px; flex: none; }
.sheet-head h2 { flex: 1; font-size: 20px; font-weight: 750; }
.sheet-body { overflow: auto; padding: 4px 20px 20px; overscroll-behavior: contain; }
.sheet.small .sheet-body { padding-top: 16px; }
@media (min-width: 760px) {
  .sheet { align-items: center; padding: 24px; }
  .sheet-card { width: min(560px, 100%); border-radius: 22px; border-bottom: 1px solid var(--line-2); max-height: min(760px, calc(100% - 48px)); padding-bottom: 0; animation-name: popIn; }
  .sheet-card.wide { width: min(860px, 100%); }
  .sheet.small .sheet-card { width: min(420px, 100%); }
  .sheet-grab { display: none; }
  .sheet-head { padding-top: 14px; }
  .sheet.closing .sheet-card { animation: popOut .14s ease both; }
}
.dialog { display: grid; gap: 14px; }
.dialog-msg { margin: 0; font-size: 18px; font-weight: 600; font-family: var(--font-head); }
.dialog-detail { margin: -6px 0 0; color: var(--soft); font-size: 15px; }
.dialog-row { display: flex; gap: 10px; justify-content: flex-end; }
.dialog-row .btn { min-width: 96px; }

.menu-list { display: grid; gap: 6px; }
.menu-item { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 54px; padding: 8px 14px; border-radius: var(--r);
  background: var(--card-2); border: 1px solid var(--line); text-align: left; font-weight: 600; font-size: 16px; }
.menu-item:hover { background: var(--card-3); }
.menu-item .ico { width: 24px; height: 24px; color: var(--soft); }
.menu-item small { display: block; font-weight: 400; color: var(--soft); font-size: 14px; }
.menu-item.danger { color: #ffb4ad; }
.menu-item.danger .ico { color: #ff8a80; }

@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes slideUp { from { transform: translateY(40px); opacity: .4; } }
@keyframes slideDown { to { transform: translateY(40px); opacity: 0; } }
@keyframes popIn { from { transform: scale(.96) translateY(8px); opacity: 0; } }
@keyframes popOut { to { transform: scale(.97); opacity: 0; } }

/* ======================================================================
   HOME
   ====================================================================== */
.home { min-height: 100%; padding: calc(18px + var(--sat)) calc(18px + var(--sar)) calc(40px + var(--sab)) calc(18px + var(--sal));
  max-width: 1240px; margin: 0 auto; position: relative; isolation: isolate; }
.home::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(60vmax 40vmax at 85% -10%, rgba(255,91,61,.16), transparent 60%),
              radial-gradient(50vmax 40vmax at -10% 30%, rgba(169,139,255,.12), transparent 60%),
              radial-gradient(50vmax 30vmax at 50% 110%, rgba(59,184,245,.08), transparent 60%), var(--bg); }
.home-top { display: flex; align-items: center; gap: 12px; padding: 8px 0 22px; flex-wrap: wrap; }
.home-top .grow { flex: 1; }
.wordmark { font-family: var(--font-display); font-weight: 400; font-size: clamp(40px, 11vw, 64px); line-height: .95; letter-spacing: .01em; margin: 0;
  background: linear-gradient(100deg, var(--hot) 0%, #ff8a3d 45%, var(--gold) 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 rgba(120,30,10,.55)); }
.home-sub { color: var(--soft); font-size: 16px; margin: 4px 0 0; }
.hub-link { display: inline-block; margin: 0 0 10px; padding: 6px 2px; color: var(--soft); font-size: 15px; font-weight: 600;
  text-decoration: none; }
.hub-link:hover, .hub-link:focus-visible { color: var(--ink); }
@media (max-width: 520px) {
  .home-top { flex-wrap: nowrap; align-items: flex-start; }
  /* a bare arrow said nothing: keep a short word under it */
  .home-top .btn { flex-direction: column; gap: 0; min-width: 64px; padding: 4px 6px; min-height: 52px; }
  .home-top .btn .btn-label { font-size: 14px; }
  .home-sub { font-size: 15px; }
}
.home-section { margin-top: 18px; }
.row-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.row-head h2 { font-size: 22px; font-weight: 750; }
.row-head .grow { flex: 1; }
.row-head .count { color: var(--dim); font-size: 15px; }
.games-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 14px; }
@media (max-width: 520px) { .games-grid { grid-template-columns: 1fr 1fr; gap: 10px; } }
.gcard { position: relative; display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  overflow: hidden; transition: transform .15s, border-color .15s, box-shadow .15s; text-align: left; padding: 0; color: inherit; }
.gcard:hover { transform: translateY(-2px); border-color: var(--line-2); box-shadow: var(--shadow); }
.gcard-open { display: block; padding: 0; border: 0; background: none; text-align: left; width: 100%; }
.gthumb { aspect-ratio: 16 / 9; width: 100%; display: block; background: #12101b center / cover no-repeat; border-bottom: 1px solid var(--line); }
.gthumb.empty { display: grid; place-items: center; color: var(--dim); }
.gmeta { padding: 10px 12px 12px; display: flex; align-items: flex-start; gap: 6px; }
.gmeta .txt { flex: 1; min-width: 0; }
/* two lines before the …, so "Robo Jump copy" never looks just like "Robo Jump" */
.gname { font-family: var(--font-head); font-weight: 700; font-size: 16px; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical;
  -webkit-line-clamp: 2; line-clamp: 2; overflow-wrap: anywhere; line-height: 1.25; }
.gwhen { color: var(--dim); font-size: 14px; }
.gcard .gmore { margin: -6px -6px 0 0; color: var(--soft); }
.gbadge { position: absolute; top: 8px; left: 8px; background: rgba(10,8,16,.75); border: 1px solid rgba(51,209,122,.5); color: #7ef0ad; font-size: 14px;
  font-weight: 700; padding: 2px 8px; border-radius: 999px; letter-spacing: .02em; }
.gnew { border: 2px dashed rgba(255,91,61,.45); background: linear-gradient(160deg, rgba(255,91,61,.14), rgba(255,181,61,.06)); min-height: 100%;
  display: grid; place-items: center; text-align: center; padding: 22px 12px; gap: 6px; cursor: pointer; color: var(--ink); }
.gnew:hover { border-color: var(--hot); }
.gnew .plus { width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; background: var(--hot); color: var(--hot-ink); box-shadow: 0 6px 0 #a3301b; }
.gnew .plus .ico { width: 30px; height: 30px; }
.gnew b { font-family: var(--font-head); font-size: 18px; }
.gnew > span { color: var(--soft); font-size: 14px; }
.home-empty { color: var(--soft); padding: 8px 2px; font-size: 15px; }
.home-note { margin-top: 10px; color: var(--gold); font-size: 14px; }
.gallery-host { min-height: 120px; }
.placeholder { border: 1px dashed var(--line-2); border-radius: var(--r-lg); padding: 22px; color: var(--soft); text-align: center; background: rgba(255,255,255,.02); font-size: 15px; }
.placeholder b { color: var(--ink); display: block; font-family: var(--font-head); font-size: 17px; margin-bottom: 4px; }

/* the tabs an admin account sees (My games / Admin) */
.home-tabs { display: inline-flex; gap: 4px; padding: 4px; margin: 0 0 6px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.home-tabs[hidden] { display: none; }
.home-tab { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 16px; border: 0; border-radius: 10px; background: none;
  color: var(--soft); font-family: var(--font-head); font-weight: 700; font-size: 15px; }
.home-tab .ico { width: 18px; height: 18px; color: var(--gold); }
.home-tab[aria-selected="true"] { background: var(--card-3); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }
.home-pane[hidden] { display: none; }
.gbadge.admin { border-color: rgba(255,181,61,.6); color: var(--gold); }

/* ADMIN tab */
.adm-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 12px 0 10px; }
.adm-who { margin: 0; color: var(--soft); font-size: 15px; }
.adm-who b { color: var(--ink); }
.adm-desk { color: var(--gold); font-weight: 650; font-size: 15px; text-decoration: none; padding: 8px 0; }
.adm-desk:hover { text-decoration: underline; }
.adm-seg { display: flex; gap: 6px; margin: 0 0 14px; flex-wrap: wrap; }
.adm-segbtn { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent; color: var(--soft); font-weight: 650; }
.adm-segbtn[aria-selected="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.adm-msg { color: var(--soft); }
.adm-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 12px; }
.adm-card { display: grid; grid-template-columns: 168px 1fr; gap: 14px; align-items: start; padding: 12px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--r-lg); }
.adm-card.is-hidden { opacity: .7; }
.adm-card .adm-thumb { border-radius: 10px; border: 1px solid var(--line); }
.adm-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.adm-title { font-family: var(--font-head); font-weight: 750; font-size: 17px; overflow-wrap: anywhere; }
.adm-sub { color: var(--soft); font-size: 14px; }
.adm-sub b { color: var(--ink); font-weight: 650; }
.adm-rep { color: #ffb4ad; }
.adm-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.adm-chip { font-size: 14px; font-weight: 700; letter-spacing: .01em; padding: 2px 9px; border-radius: 999px;
  border: 1px solid var(--line-2); color: var(--soft); }
.adm-chip.s-live { color: #7ef0ad; border-color: rgba(51,209,122,.5); }
.adm-chip.s-hidden, .adm-chip.s-sent-back { color: #ffb4ad; border-color: rgba(255,91,91,.45); }
.adm-chip.s-new, .adm-chip.s-update, .adm-chip.s-waiting { color: #9fd8ff; border-color: rgba(59,184,245,.5); }
.adm-chip.s-real { color: var(--gold); border-color: rgba(255,181,61,.6); }
.adm-reason { margin: 2px 0 0; color: var(--soft); font-size: 14px; }
.adm-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.adm-actions .btn { min-height: 40px; padding: 0 12px; font-size: 15px; }
.adm-quicks { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.adm-quick { min-height: 40px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--card-2); color: var(--ink); font-size: 14px; font-weight: 600; }
.adm-quick[aria-pressed="true"] { background: rgba(255,181,61,.16); border-color: rgba(255,181,61,.6); color: var(--gold); }
.adm-reason-box { min-height: 84px; resize: vertical; }
@media (max-width: 560px) {
  .adm-card { grid-template-columns: 1fr; }
  .adm-actions .btn { flex: 1 1 auto; }
}
/* the editor's SAVE TO LIVE button (an admin editing a published game) */
.btn.live { background: var(--gold); border-color: transparent; color: #1f1405; font-family: var(--font-head); font-weight: 800; }
.btn.live:hover:not(:disabled) { background: #ffc766; }
.ed-adminbar { display: flex; align-items: center; gap: 10px; padding: 6px calc(12px + var(--sar)) 6px calc(12px + var(--sal)); flex: none;
  background: rgba(255,181,61,.12); border-bottom: 1px solid rgba(255,181,61,.35); color: var(--gold); font-size: 14px; font-weight: 600; }
.ed-adminbar b { color: var(--ink); }
.ed-adminbar .grow { flex: 1; }
.ed-adminbar .btn { min-height: 36px; padding: 0 12px; }
.ed-adminwords { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 760px) { .ed-adminlong { display: none; } }

/* template chooser */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 12px; }
@media (max-width: 520px) { .tpl-grid { grid-template-columns: 1fr 1fr; gap: 10px; } }
.tpl { display: flex; flex-direction: column; text-align: left; padding: 0; background: var(--card-2); border: 1px solid var(--line); border-radius: var(--r);
  overflow: hidden; transition: border-color .15s, transform .12s; }
.tpl:hover { border-color: var(--gold); transform: translateY(-1px); }
.tpl .gthumb { border-radius: 0; }
.tpl b { font-family: var(--font-head); font-size: 16px; padding: 9px 12px 0; }
.tpl span { color: var(--soft); font-size: 14px; padding: 2px 12px 12px; line-height: 1.35; }
.tpl.blank .gthumb { background: repeating-linear-gradient(45deg, #15121e 0 10px, #181424 10px 20px); }
/* the home screen's "Start from an example" row: 2 across on phones and tablets, 4 on a big screen */
.starter-grid { grid-template-columns: 1fr 1fr; }
@media (min-width: 900px) { .starter-grid { grid-template-columns: repeat(4, 1fr); } }
.starter-grid .tpl { background: var(--card); }
.starter-grid .tpl span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden;
  padding-bottom: 0; margin-bottom: 12px; }

/* ======================================================================
   EDITOR
   ====================================================================== */
.ed { position: fixed; inset: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }
.ed-top { flex: none; height: calc(var(--top-h) + var(--sat)); padding: var(--sat) calc(8px + var(--sar)) 0 calc(6px + var(--sal));
  display: flex; align-items: center; gap: 6px; background: var(--bg-2); border-bottom: 1px solid var(--line); z-index: 20; }
.ed-name { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; height: 44px; padding: 0 10px; border-radius: 12px; border: 1px solid transparent;
  background: transparent; font-family: var(--font-head); font-weight: 750; font-size: 17px; text-align: left; }
.ed-name:hover { background: rgba(255,255,255,.05); }
.ed-name span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-name .ico { width: 16px; height: 16px; color: var(--dim); }
.ed-save { color: var(--dim); font-size: 14px; white-space: nowrap; display: none; }
.ed-tabs-top { display: none; }
.ed-top .undo-group { display: none; gap: 2px; }
.ed-main { flex: 1; min-height: 0; display: flex; position: relative; }
.ed-left, .ed-right { background: var(--bg-2); min-height: 0; }
.ed-center { flex: 1; min-width: 0; position: relative; display: flex; }
.pane { position: absolute; inset: 0; display: none; min-height: 0; }
.ed[data-tab="scene"] .pane-scene, .ed[data-tab="code"] .pane-code, .ed[data-tab="art"] .pane-art { display: flex; }
.pane-code, .pane-art { flex-direction: column; }
.pane-host { flex: 1; min-height: 0; position: relative; overflow: auto; }
.ed-tabs { flex: none; display: grid; grid-template-columns: repeat(3, 1fr); height: calc(var(--tabs-h) + var(--sab)); padding: 0 var(--sar) var(--sab) var(--sal);
  background: var(--bg-2); border-top: 1px solid var(--line); z-index: 20; }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 0; background: none; color: var(--dim);
  font-family: var(--font-head); font-weight: 750; font-size: 14px; letter-spacing: .06em; position: relative; }
.tab .ico { width: 24px; height: 24px; }
.tab[aria-selected="true"] { color: var(--ink); }
.tab[aria-selected="true"]::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: var(--hot); }

/* phone: left (tree) and right (inspector) are sheets over the stage */
@media (max-width: 759.98px) {
  .ed-left { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; height: min(72vh, 620px); border-radius: 22px 22px 0 0; border: 1px solid var(--line-2);
    border-bottom: 0; transform: translateY(105%); transition: transform .22s cubic-bezier(.2,.9,.3,1); display: flex; flex-direction: column;
    padding-bottom: var(--sab); box-shadow: var(--shadow); }
  .ed-left.open { transform: none; }
  .ed[data-tab="code"] .ed-left, .ed[data-tab="art"] .ed-left { display: none; }
  .ed-scrim { position: fixed; inset: 0; z-index: 55; background: rgba(5,4,10,.55); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .ed-scrim.show { opacity: 1; pointer-events: auto; }
  .ed-right { position: absolute; left: 0; right: 0; bottom: 0; z-index: 30; max-height: 0; overflow: hidden; border-radius: 20px 20px 0 0;
    border: 1px solid var(--line-2); border-bottom: 0; box-shadow: 0 -10px 30px rgba(0,0,0,.45); transition: max-height .22s cubic-bezier(.2,.9,.3,1);
    display: flex; flex-direction: column; }
  .ed-right.peek { max-height: var(--peek-h, 168px); }
  .ed-right.open { max-height: 64%; }
  .ed[data-tab="code"] .ed-right, .ed[data-tab="art"] .ed-right { display: none; }
  .ed-right .insp-grab { display: block; }
  .stage-tools .only-desktop { display: none; }
}
@media (min-width: 760px) {
  :root { --top-h: 60px; }
  .ed-tabs { display: none; }
  .ed-tabs-top { display: flex; gap: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 4px; margin: 0 8px; }
  .ed-tabs-top .tab { flex-direction: row; gap: 8px; height: 40px; padding: 0 14px; border-radius: 10px; font-size: 14px; }
  .ed-tabs-top .tab .ico { width: 20px; height: 20px; }
  .ed-tabs-top .tab[aria-selected="true"] { background: var(--card-3); }
  .ed-tabs-top .tab[aria-selected="true"]::before { display: none; }
  .ed-name { flex: 0 1 auto; max-width: 300px; }
  .ed-save { display: inline; }
  .ed-top .grow { flex: 1; }
  .ed-top .undo-group { display: flex; }
  .ed-left { width: 264px; flex: none; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
  .ed-right { width: 320px; flex: none; border-left: 1px solid var(--line); display: flex; flex-direction: column; }
  .ed[data-tab="art"] .ed-left, .ed[data-tab="art"] .ed-right, .ed[data-tab="code"] .ed-right { display: none; }
  .ed-scrim, .insp-grab, .only-phone { display: none !important; }
  .stage-tools .only-phone { display: none; }
}
/* tablets (760-1099): tree slides in from the left over the stage, so the
   stage keeps the room; the inspector stays as a column on the right */
@media (min-width: 760px) and (max-width: 1099.98px) {
  .ed-left { position: absolute; left: 0; top: 0; bottom: 0; z-index: 60; width: 300px; transform: translateX(-102%);
    transition: transform .22s cubic-bezier(.2,.9,.3,1); box-shadow: var(--shadow); }
  .ed-left.open { transform: none; }
  .ed[data-tab="code"] .ed-left { display: none; }
  .ed-scrim { display: block !important; position: absolute; inset: 0; z-index: 55; background: rgba(5,4,10,.45); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .ed-scrim.show { opacity: 1; pointer-events: auto; }
  .pane-code .kind-strip { display: flex !important; }
}
@media (min-width: 1100px) { .only-compact { display: none !important; } }
@media (min-width: 1280px) { .ed-left { width: 288px; } .ed-right { width: 344px; } }
/* big screens can afford slightly smaller labels (phones keep 14px+) */
@media (min-width: 760px) {
  .ed-save, .tree-head h3, .tree-group, .tree-kind, .sec > h4 { font-size: 13px; }
  .tree-tag { font-size: 12px; }
}

/* ---------- stage ---------- */
.stage { position: absolute; inset: 0; overflow: hidden; touch-action: none; background: #07060c; outline: none; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage.panning, .stage.space { cursor: grab; }
.stage.panning:active { cursor: grabbing; }
.stage-tools { position: absolute; z-index: 5; display: flex; gap: 6px; pointer-events: none; }
.stage-tools > * { pointer-events: auto; }
.stage-tools.tl { top: 10px; left: 10px; right: 230px; }
@media (min-width: 760px) { .stage-tools.tl { right: 130px; } }
.stage-tools.tl .scene-pill { min-width: 0; max-width: 100%; }
.stage-tools.tr { top: 10px; right: 10px; }
.stage-tools.bl { bottom: calc(14px + var(--sheet-lift, 0px)); left: 12px; transition: bottom .22s; }
.stage-tools.br { bottom: calc(14px + var(--sheet-lift, 0px)); right: 12px; transition: bottom .22s; }
.tool { min-height: 44px; min-width: 44px; padding: 0 12px; border-radius: 14px; background: rgba(22,19,31,.86); border: 1px solid var(--line-2); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-weight: 600; font-size: 14px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.tool:hover:not(:disabled) { background: rgba(37,32,52,.95); }
.tool:disabled { opacity: .35; }
.tool.square { padding: 0; width: 44px; }
.tool.on { color: var(--gold); border-color: rgba(255,181,61,.55); background: rgba(60,42,14,.85); }
.tool .ico { width: 20px; height: 20px; }
.scene-pill { max-width: 100%; }
.scene-pill span:not(.ico) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fab { width: 60px; height: 60px; border-radius: 20px; border: 0; background: var(--hot); color: var(--hot-ink); display: grid; place-items: center;
  box-shadow: 0 6px 0 #a3301b, 0 10px 24px rgba(0,0,0,.5); transition: transform .1s, box-shadow .1s; }
.fab:active { transform: translateY(4px); box-shadow: 0 2px 0 #a3301b, 0 6px 14px rgba(0,0,0,.5); }
.fab .ico { width: 30px; height: 30px; }
.zoom-chip { min-width: 58px; font-variant-numeric: tabular-nums; }
.stage-hint { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 4; pointer-events: none; text-align: center; color: var(--soft);
  font-size: 15px; background: rgba(10,8,16,.7); border: 1px solid var(--line); padding: 14px 18px; border-radius: 16px; max-width: 280px; }
.stage-hint b { display: block; color: var(--ink); font-family: var(--font-head); font-size: 17px; margin-bottom: 2px; }

/* ---------- add sheet ---------- */
.add-swatches { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 14px; }
.add-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
@media (max-width: 420px) { .add-grid { grid-template-columns: 1fr 1fr; } }
.add-item { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px; min-height: 104px; text-align: left;
  border-radius: var(--r); background: var(--card-2); border: 1px solid var(--line); transition: border-color .15s, background .15s; }
.add-item:hover { border-color: var(--gold); background: var(--card-3); }
.add-item .pic { width: 100%; height: 40px; display: flex; align-items: center; }
.add-item b { font-family: var(--font-head); font-size: 16px; }
.add-item span { color: var(--soft); font-size: 14px; line-height: 1.3; }
.add-label { font-family: var(--font-head); font-weight: 700; color: var(--soft); font-size: 14px; letter-spacing: .06em; text-transform: uppercase; margin: 16px 0 8px; }
.add-label:first-child { margin-top: 0; }
.add-art { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.add-art button { flex: none; width: 84px; display: grid; gap: 4px; justify-items: center; padding: 8px; border-radius: 12px; background: var(--card-2); border: 1px solid var(--line); font-size: 14px; }
.add-art button:hover { border-color: var(--gold); }
.add-art img { width: 56px; height: 56px; object-fit: contain; image-rendering: pixelated; }

/* ---------- colour swatches ---------- */
.swatch { width: 36px; height: 36px; border-radius: 11px; border: 2px solid rgba(255,255,255,.12); flex: none; padding: 0; position: relative;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.22); transition: transform .1s; }
.swatch:hover { transform: scale(1.06); }
.swatch[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--bg-2), 0 0 0 4px var(--ink); }
.swatch.none { background: repeating-conic-gradient(#2a2538 0 25%, #1a1724 0 50%) 50% / 12px 12px; }
.swatch.pick { background: conic-gradient(from 90deg, #ff5b5b, #ffd23f, #4ade80, #2ec4b6, #3b9bff, #a98bff, #ff7ac6, #ff5b5b); overflow: hidden; }
.swatch.pick input { position: absolute; inset: -8px; width: calc(100% + 16px); height: calc(100% + 16px); opacity: 0; cursor: pointer; }
@media (pointer: coarse) { .swatch { width: 40px; height: 40px; } }

/* ---------- tree ---------- */
.tree { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.tree-head { flex: none; padding: 12px 12px 8px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--line); }
.tree-head .row { display: flex; gap: 6px; align-items: center; }
.tree-head h3 { font-size: 14px; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); font-weight: 700; flex: 1; }
.scene-select { flex: 1; min-width: 0; }
.tree-list { position: relative; flex: 1; overflow: auto; padding: 6px 6px 14px; overscroll-behavior: contain; }
.tree-group { font-size: 14px; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); font-weight: 700; padding: 12px 8px 4px; display: flex; gap: 6px; align-items: center; }
.tree-row { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 40px; padding: 0 4px 0 8px; border-radius: 11px; border: 1px solid transparent;
  background: none; text-align: left; color: var(--ink); font-size: 15px; }
.tree-row:hover { background: rgba(255,255,255,.04); }
.tree-row.sel { background: rgba(255,181,61,.13); border-color: rgba(255,181,61,.4); }
.tree-row.hidden .tree-name { opacity: .45; }
.tree-chip { width: 22px; height: 22px; border-radius: 7px; flex: none; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.14); overflow: hidden; }
.tree-chip img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.tree-chip .ico { width: 14px; height: 14px; color: #fff; }
.tree-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.tree-kind { color: var(--dim); font-size: 14px; white-space: nowrap; max-width: 40%; overflow: hidden; text-overflow: ellipsis; }
.tree-eye { width: 34px; height: 34px; border-radius: 9px; border: 0; background: none; color: var(--dim); display: grid; place-items: center; flex: none; }
.tree-eye:hover { color: var(--ink); background: rgba(255,255,255,.06); }
.tree-eye .ico { width: 18px; height: 18px; }
.tree-empty { color: var(--dim); padding: 14px 10px; font-size: 15px; }
.tree-tag { font-size: 14px; line-height: 1.2; font-weight: 700; color: var(--gold); border: 1px solid rgba(255,181,61,.4); border-radius: 6px; padding: 0 5px; }
@media (max-width: 759.98px) {
  .tree-row { min-height: 48px; font-size: 16px; }
  .tree-kind { font-size: 14px; }
  .tree-eye { width: 44px; height: 44px; }
  .tree-group, .tree-head h3 { font-size: 14px; }
}

/* ---------- inspector ---------- */
.insp { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.insp-grab { display: none; width: 100%; height: 22px; border: 0; background: none; position: relative; flex: none; padding: 0; }
.insp-grab::after { content: ""; position: absolute; left: 50%; top: 9px; width: 44px; height: 5px; margin-left: -22px; border-radius: 3px; background: var(--line-2); }
.insp-scroll { flex: 1; overflow: auto; padding: 12px 14px 24px; overscroll-behavior: contain; }
.insp-head { display: flex; align-items: center; gap: 8px; }
.insp-type { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--card-2); border: 1px solid var(--line-2); }
.insp-type .ico { width: 22px; height: 22px; }
.insp-title { flex: 1; min-width: 0; }
.insp-title input { font-family: var(--font-head); font-weight: 750; font-size: 18px; background: transparent; border-color: transparent; padding: 6px 8px; min-height: 40px; }
.insp-title input:hover { border-color: var(--line-2); }
.insp-quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 10px 0 0; }
.qbtn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; border-radius: 12px;
  background: var(--card-2); border: 1px solid var(--line-2); color: var(--ink); font-size: 14px; font-weight: 600; padding: 4px 2px; }
.qbtn:hover { background: var(--card-3); }
.qbtn:active { transform: translateY(1px); }
.qbtn .ico { width: 20px; height: 20px; }
.qbtn.danger { color: #ffb4ad; }
.qbtn.danger .ico { color: #ff8a80; }
.code-btn { min-height: 40px; padding: 0 12px 0 10px; font-size: 15px; flex: none; }
.code-btn .ico { width: 18px; height: 18px; }
.peek-colours { margin-top: 10px; }
@media (max-width: 759.98px) {
  .swatches.strip { flex-wrap: nowrap; overflow-x: auto; padding: 4px 4px 6px; margin: 0 -4px; scrollbar-width: none; }
  .swatches.strip::-webkit-scrollbar { display: none; }
}
.sec { border-top: 1px solid var(--line); padding: 12px 0 2px; margin-top: 12px; }
.sec > h4 { margin: 0 0 8px; font: 700 14px var(--font-head); letter-spacing: .08em; text-transform: uppercase; color: var(--dim); display: flex; gap: 8px; align-items: center; }
.frow { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.frow.one { grid-template-columns: 1fr; }
.frow.three { grid-template-columns: 1fr 1fr 1fr; }
.flabel { display: block; font-size: 14px; color: var(--soft); margin-bottom: 4px; font-weight: 600; }
.fhelp { font-size: 14px; color: var(--dim); margin: 2px 0 8px; line-height: 1.35; }
.stepper { display: flex; align-items: stretch; background: var(--bg); border: 1px solid var(--line-2); border-radius: 12px; overflow: hidden; height: 44px; }
.stepper:focus-within { border-color: var(--gold); }
.stepper .lab { display: grid; place-items: center; padding: 0 8px 0 10px; color: var(--dim); font-weight: 700; font-size: 14px; cursor: ew-resize; user-select: none; touch-action: none; min-width: 28px; }
.stepper input { flex: 1; min-width: 0; width: 100%; border: 0; background: none; text-align: center; font-variant-numeric: tabular-nums; font-size: 16px; padding: 0; }
.stepper input:focus { outline: none; }
.stepper button { width: 34px; border: 0; background: rgba(255,255,255,.04); color: var(--soft); display: grid; place-items: center; flex: none; }
.stepper button:hover { background: rgba(255,255,255,.1); color: var(--ink); }
.stepper button .ico { width: 16px; height: 16px; }
.seg { display: flex; gap: 4px; background: var(--bg); border: 1px solid var(--line-2); border-radius: 12px; padding: 3px; }
.seg button { flex: 1; min-height: 38px; border: 0; border-radius: 9px; background: none; color: var(--soft); font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.seg button[aria-pressed="true"] { background: var(--card-3); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }
.seg button .ico { width: 18px; height: 18px; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice { text-align: left; padding: 10px 12px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line-2); min-height: 72px; display: grid; gap: 2px; align-content: start; }
.choice b { font-family: var(--font-head); font-size: 15px; display: flex; align-items: center; gap: 6px; }
.choice span { font-size: 14px; color: var(--dim); line-height: 1.3; }
.choice[aria-pressed="true"] { border-color: var(--cat-physics); background: rgba(46,196,182,.12); }
.choice[aria-pressed="true"] b { color: #7fe8de; }
.toggle-row { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.toggle-row .t { flex: 1; }
.toggle-row .t b { display: block; font-weight: 600; font-size: 15px; }
.toggle-row .t span { display: block; color: var(--dim); font-size: 14px; line-height: 1.3; }
.switch { width: 52px; height: 32px; border-radius: 16px; background: var(--card-3); border: 1px solid var(--line-2); position: relative; flex: none; padding: 0; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--soft); transition: transform .15s, background .15s; }
.switch[aria-checked="true"] { background: rgba(46,196,182,.35); border-color: var(--cat-physics); }
.switch[aria-checked="true"]::after { transform: translateX(20px); background: #fff; }
.range { width: 100%; accent-color: var(--hot); height: 32px; }
.swatches { display: flex; flex-wrap: wrap; gap: 7px; }
.assets-pick { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; }
.asset-btn { flex: none; width: 64px; height: 64px; border-radius: 12px; background: repeating-conic-gradient(#221d2f 0 25%, #1a1724 0 50%) 50% / 12px 12px;
  border: 2px solid var(--line-2); padding: 4px; display: grid; place-items: center; color: var(--soft); font-size: 14px; }
.asset-btn img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.asset-btn[aria-pressed="true"] { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(255,181,61,.25); }
.kind-row { display: flex; gap: 6px; }
.kind-row select { flex: 1; min-width: 0; }
.insp-empty { color: var(--soft); font-size: 15px; }
.insp-note { background: rgba(255,181,61,.08); border: 1px solid rgba(255,181,61,.25); border-radius: 12px; padding: 10px 12px; font-size: 14px; color: #f2d7a6; margin-top: 8px; }
.textarea { min-height: 72px; resize: vertical; font-size: 16px; line-height: 1.35; }
.multi-count { font-family: var(--font-head); font-size: 18px; font-weight: 750; }

/* ---------- code + art panes (host areas; the helpers style their insides) ---------- */
.kind-strip { position: relative; flex: none; display: flex; gap: 6px; overflow-x: auto; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--bg-2); scrollbar-width: none; }
.kind-strip::-webkit-scrollbar { display: none; }
.kchip { flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px 0 8px; border-radius: 12px; background: var(--card-2);
  border: 1px solid var(--line); font-weight: 600; font-size: 15px; }
.kchip[aria-pressed="true"] { background: rgba(255,181,61,.15); border-color: rgba(255,181,61,.55); color: var(--gold); }
.kchip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cat-making); }
.klist { padding: 8px 8px 16px; overflow: auto; flex: 1; }
.klist .tree-row { min-height: 44px; }
.klist .has-code { width: 8px; height: 8px; border-radius: 50%; background: var(--cat-making); flex: none; }
@media (min-width: 1100px) { .pane-code .kind-strip { display: none; } }
@media (max-width: 759.98px) { .ed-left .klist-wrap { display: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* the left panel holds the scene tree OR (in the code tab) the kinds list */
.ed:not([data-tab="code"]) .klist-wrap { display: none; }
.ed[data-tab="code"] .ed-left .scene-tree { display: none; }
.pane-scene.insp-open .stage-tools.bl, .pane-scene.insp-open .stage-tools.br { display: none; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; background: rgba(255,255,255,.06); padding: 1px 5px; border-radius: 6px; color: #e9ddff; }

/* ======================================================================
   ROUND 2: 3D badge, desktop labels, the "More" fold, first-run tips
   ====================================================================== */
.badge3d { gap: 6px; padding: 0 10px 0 6px; color: var(--ink); }
.badge3d b { display: inline-grid; place-items: center; height: 28px; padding: 0 7px; border-radius: 8px; font: 400 14px var(--font-display);
  background: linear-gradient(135deg, var(--cat-motion), var(--cat-looks)); color: #0b0a14; letter-spacing: .04em; }
.badge3d span { color: var(--soft); font-size: 14px; white-space: nowrap; }
@media (max-width: 420px) { .badge3d span { display: none; } }

/* icon buttons say what they are on a big screen with a mouse */
.btn .desk, .tool .desk, .fab .fab-label { display: none; }
@media (min-width: 1100px) and (hover: hover) {
  .btn.square.has-desk { width: auto; padding: 0 12px 0 10px; }
  .btn .desk { display: inline; font-size: 14px; font-weight: 600; }
  .btn.ghost.has-desk { color: var(--soft); }
  .btn.ghost.has-desk:hover:not(:disabled) { color: var(--ink); }
  .tool.square.has-desk { width: auto; padding: 0 12px 0 10px; }
  .tool .desk { display: inline; }
  .fab { width: auto; padding: 0 20px 0 14px; gap: 6px; display: inline-flex; align-items: center; }
  .fab .fab-label { display: inline; font: 800 18px var(--font-head); letter-spacing: .02em; }
}
/* touch: press and hold a button for its tip */
.touch-tip { position: fixed; z-index: 300; max-width: min(300px, calc(100% - 16px)); padding: 9px 12px; border-radius: 12px; pointer-events: none;
  background: #2a2340; border: 1px solid var(--line-2); color: var(--ink); font-size: 15px; font-weight: 600; box-shadow: var(--shadow); animation: fadeIn .12s ease both; }

/* inspector: picture fitting, presets, the fold */
.fit-pic { width: 100%; }
.preset { min-height: 44px; padding: 0 10px; font-size: 14px; }
.rename-kind { flex: none; padding: 0 12px; font-size: 14px; }
.more-box { border-top: 1px solid var(--line); margin-top: 14px; }
.more-box > summary { list-style: none; display: flex; align-items: center; gap: 10px; min-height: 48px; cursor: pointer; padding: 6px 2px;
  font: 700 15px var(--font-head); color: var(--soft); }
.more-box > summary::-webkit-details-marker { display: none; }
.more-box > summary::before { content: ""; width: 9px; height: 9px; border-right: 2.5px solid currentColor; border-bottom: 2.5px solid currentColor;
  transform: rotate(-45deg); transition: transform .15s; margin: 0 4px 0 6px; }
.more-box[open] > summary::before { transform: rotate(45deg); }
.more-box > summary small { font: 400 14px var(--font-body); color: var(--dim); }
.more-box > summary:hover { color: var(--ink); }
.more-body { padding: 4px 0 6px; display: grid; gap: 12px; }
.choices.stack { grid-template-columns: 1fr; gap: 6px; }
.choices.stack .choice { min-height: 0; grid-template-columns: auto 1fr; align-items: baseline; column-gap: 10px; padding: 10px 12px; }
.tree-empty b { color: var(--ink); }

/* first-run tips */
.coach-layer { position: fixed; inset: 0; z-index: 150; pointer-events: none; }
.coach-ring { position: fixed; border-radius: 18px; border: 3px solid var(--gold); box-shadow: 0 0 0 4px rgba(255,181,61,.25);
  transition: left .2s, top .2s, width .2s, height .2s; animation: coachPulse 1.6s ease-in-out infinite; }
.coach { position: fixed; width: min(300px, calc(100% - 16px)); pointer-events: auto; padding: 14px 14px 10px; border-radius: 16px; background: #221c33;
  border: 1px solid rgba(255,181,61,.55); box-shadow: var(--shadow); animation: popIn .18s ease both; }
.coach b { display: block; font: 800 18px var(--font-head); color: var(--gold); margin-bottom: 2px; }
.coach p { margin: 0 0 10px; font-size: 16px; line-height: 1.35; }
.coach-row { display: flex; align-items: center; gap: 6px; }
.coach-count { flex: 1; color: var(--dim); font-size: 14px; }
.coach-skip { padding: 0 10px; color: var(--soft); font-size: 14px; }
.coach-next { padding: 0 16px; }
.coach-arrow { position: absolute; left: var(--arrow-x, 50%); top: -8px; width: 14px; height: 14px; margin-left: -7px; transform: rotate(45deg);
  background: #221c33; border-left: 1px solid rgba(255,181,61,.55); border-top: 1px solid rgba(255,181,61,.55); }
.coach.up .coach-arrow { top: auto; bottom: -8px; border: 0; border-right: 1px solid rgba(255,181,61,.55); border-bottom: 1px solid rgba(255,181,61,.55); }
@keyframes coachPulse { 50% { box-shadow: 0 0 0 9px rgba(255,181,61,.14); } }
/* a tablet held upright: the game's name gets the room "Saved" was using */
@media (min-width: 760px) and (max-width: 979.98px) { .ed-save { display: none; } }

/* ======================================================================
   BUG HUNT (round 2): fixes found by playing it as a kid would, on a phone and an iPad
   ====================================================================== */
/* the scenes sheet: a scene's name shrinks (…) so its four buttons always fit */
.menu-item > span { min-width: 0; }
.scene-row { gap: 2px; padding-right: 6px; }
.scene-row > .btn.square { flex: none; }
.scene-go { flex: 1; min-width: 0; justify-content: flex-start; padding: 0 4px; min-height: 44px; font-size: 16px; }
.scene-go-t { min-width: 0; text-align: left; display: grid; }
.scene-go-t b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scene-go-t small { white-space: normal; line-height: 1.25; }
.scene-go-t b { font-weight: 600; }
/* phones: a fifth quick button, "More", opens the whole inspector */
@media (max-width: 759.98px) { .insp-quick { grid-template-columns: repeat(5, 1fr); gap: 5px; } .insp-close { flex: none; } }
/* small link-like buttons: compact with a mouse, a full 44px for a finger */
.link-btn { min-height: 34px; }

/* iPad (and any touch screen): the tablet layout borrowed the desktop's sizes —
   tabs 40px tall, steppers' +/- 34px wide, swatches 40px. A finger needs 44. */
@media (pointer: coarse) {
  .ed-tabs-top .tab { height: 44px; }
  .ed-tabs-top { padding: 3px; }
  .swatch { width: 44px; height: 44px; }
  .link-btn, .seg button, .insp-title input, .code-btn { min-height: 44px; }
  .stepper { height: 46px; }
  .stepper button { width: 44px; }
  .tree-row { min-height: 48px; }
  .tree-eye { width: 44px; height: 44px; }
  /* a switch keeps its look; an invisible ring makes it a 44px+ target */
  .switch::before { content: ""; position: absolute; inset: -7px -4px; }
  .insp-grab { height: 30px; }
  .insp-grab::after { top: 12px; }
}
/* the tablet inspector is 320px: two steppers side by side left no room for
   the number between bigger buttons, so on a touch tablet they stack */
@media (pointer: coarse) and (min-width: 760px) {
  .ed-right .frow:has(> .stepper) { grid-template-columns: 1fr; }
}
.multi-tool[aria-pressed="true"] { color: var(--gold); border-color: rgba(255,181,61,.55); background: rgba(60,42,14,.9); }
/* the top bar's undo/redo are the SCENE's: on CODE and ART (which have their own) two pairs read as one
   — the top pair silently undid scene edits while you were drawing */
.ed[data-tab="code"] .ed-top .undo-group, .ed[data-tab="art"] .ed-top .undo-group { display: none; }
/* New game: "Empty game" sits up top next to the words, not only as the last card */
.tpl-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.tpl-top .fhelp { flex: 1; }
.tpl-blank-btn { flex: none; }
