/* ============================================================
   Tiny Doors — creator editor
   ============================================================ */

body.editor { min-height: 100vh; }
body.editor #foreground { z-index: 1; }
/* The chosen world, live in 3D, drifting behind the editor (2D scene stays as the fallback) */
#bg3d { position: fixed; inset: 0; z-index: 1; pointer-events: none; }
#bg3d iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; opacity: 0; transition: opacity 0.9s ease; }
#bg3d iframe.on { opacity: 1; }
body.has3d #scene, body.has3d #ambient, body.has3d #foreground { visibility: hidden; }
body.editor.sheet-open { overflow: hidden; }

.editor {
  --panel: rgba(255, 252, 245, 0.95);
  --panel-ink: #2b1d33;
  --muted: #6b5d72;
  --line: #e8dfe9;
}

/* ---------------- Top bar ---------------- */
.ed-top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  background: rgba(8, 16, 50, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
[data-theme='summer'] .ed-top { background: rgba(255, 210, 190, 0.6); }
.logo {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-family: var(--font-display);
  font-variation-settings: 'SOFT' 100, 'WONK' 1;
  font-weight: 900;
  font-style: italic;
  font-size: 1.2rem;
  text-decoration: none;
  white-space: nowrap;
}
.ed-steps {
  display: flex;
  gap: 4px;
  margin: 0 auto;
  padding: 4px;
  list-style: none;
  border-radius: 999px;
  background: var(--chip-bg);
  backdrop-filter: blur(8px);
}
.ed-steps button {
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--ink);
  font-weight: 900;
  font-size: 0.85rem;
  cursor: pointer;
  opacity: 0.75;
}
.ed-steps button:disabled { opacity: 0.35; cursor: default; }
.ed-steps li.on button { background: var(--btn); color: var(--btn-ink); opacity: 1; }
.saved { min-width: 70px; text-align: right; font-weight: 800; font-size: 0.8rem; color: var(--ink-soft); }

/* ---------------- Layout ---------------- */
.ed-main {
  position: relative;
  z-index: 2;
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 8px 16px 120px;
}
.screen[hidden] { display: none; }
.panel {
  margin: 0 auto 18px;
  padding: 26px 24px;
  border-radius: 28px;
  background: var(--panel);
  color: var(--panel-ink);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
}
.kicker {
  margin: 0 0 8px;
  font-weight: 900;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--btn);
}
.ed-h1 {
  margin: 0 0 22px;
  font-family: var(--font-display);
  font-variation-settings: 'SOFT' 100, 'WONK' 1, 'opsz' 144;
  font-weight: 900;
  font-size: clamp(2.1rem, 7vw, 3.4rem);
  font-style: normal;
  line-height: 1.02;
  letter-spacing: -0.01em;
  text-shadow: none;
}
.ed-h1 em { color: var(--btn); }
.ed-h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-variation-settings: 'SOFT' 100, 'WONK' 1, 'opsz' 96;
  font-weight: 900;
  font-style: italic;
  font-size: clamp(1.6rem, 5.5vw, 2.3rem);
  line-height: 1.05;
}
.lede { margin: 0 0 14px; font-weight: 600; font-size: 1.02rem; line-height: 1.5; color: var(--muted); }
.lede b { color: var(--panel-ink); }
.label { margin: 18px 0 8px; font-weight: 900; font-size: 0.9rem; }
.fine { margin: 12px 0 0; font-weight: 700; font-size: 0.85rem; color: var(--muted); text-align: center; }
.proto-note {
  margin: 14px 0 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: #fff5d6;
  color: #7a5a00;
  font-weight: 700;
  font-size: 0.8rem;
  text-align: center;
}

/* ---------------- 1. Start ---------------- */
.hero { max-width: 640px; margin-top: 4vh; }
.hero > .btn.big { display: block; width: 100%; margin-top: 22px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fields label, .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 900;
  font-size: 0.9rem;
}
.field small { font-weight: 700; color: var(--muted); }
.fields input, .field input, .field textarea, .tzrow select {
  width: 100%;
  padding: 13px 14px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--panel-ink);
  font: 700 1.05rem var(--font-body);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field textarea { font: 600 1.35rem/1.3 var(--font-hand); resize: vertical; min-height: 170px; }
.fields input:focus, .field input:focus, .field textarea:focus, .tzrow select:focus {
  outline: none;
  border-color: var(--btn);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--btn) 18%, transparent);
}
.shake { animation: rattle 0.45s ease-in-out; }

.theme-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.theme-card { position: relative; }
.pass-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1;
  padding: 3px 9px;
  border-radius: 999px;
  background: #fff3c4;
  color: #7a5a00;
  font-size: 0.72rem;
  font-weight: 900;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}
.world-previews { margin: 10px 0 0; font-weight: 700; font-size: 0.85rem; color: var(--muted); text-align: center; }
.world-previews a { color: var(--btn); font-weight: 900; }
.theme-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 8px 12px;
  border: 3px solid var(--line);
  border-radius: 20px;
  background: #fff;
  color: var(--panel-ink);
  text-align: left;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.theme-card svg { width: 100%; height: auto; border-radius: 13px; display: block; margin-bottom: 6px; }
.theme-card b { padding: 0 6px; font-size: 1.02rem; font-weight: 900; }
.theme-card small { padding: 0 6px; font-weight: 700; color: var(--muted); line-height: 1.35; }
.theme-card:hover { transform: translateY(-3px); }
.theme-card.on { border-color: var(--btn); box-shadow: 0 0 0 4px color-mix(in srgb, var(--btn) 20%, transparent), 0 14px 30px rgba(0, 0, 0, 0.12); }
.theme-card.on b::after { content: ' ✓'; color: var(--btn); }

/* ---------------- 2. Doors ---------------- */
.doors-panel { background: #fff8eb; }
.doors-head { text-align: center; max-width: 720px; margin: 0 auto; }
.doors-panel .ed-grid { padding-bottom: calc(var(--cw) * 0.12); }
@media (max-width: 560px) {
  .panel.doors-panel { padding: 22px 12px; }
}
.meter { max-width: 420px; margin: 0 auto 14px; font-weight: 800; font-size: 0.9rem; }
.meter .bar { height: 10px; margin-top: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.meter .bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffcf6b, var(--btn));
  transition: width 0.6s cubic-bezier(.3, 1.4, .5, 1);
}
.suggest, .idea-chips, .filter { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.chip {
  padding: 9px 14px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--panel-ink);
  font-weight: 800;
  font-size: 0.88rem;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}
.chip:hover { transform: translateY(-2px); border-color: var(--btn); }
.chip.on { background: var(--btn); border-color: var(--btn); color: var(--btn-ink); }

.ed-grid { margin: 26px auto 0; padding-top: calc(var(--cw) * 0.15); }
.ed-grid .hut { --door-delay: 0s; }
.ed-grid .hut .icon { font-size: calc(var(--cw) * 0.32); }
.ed-grid .hut.has-photo .inside { background-size: cover; background-position: center; }
.ed-grid .hut.has-photo .icon { opacity: 0 !important; }
.ed-grid .hut .badge,
.ed-grid .hut .add {
  position: absolute;
  z-index: 3;
  display: grid;
  place-items: center;
  width: calc(var(--cw) * 0.26);
  aspect-ratio: 1;
  border-radius: 50%;
  font-weight: 900;
  font-size: calc(var(--cw) * 0.15);
  pointer-events: none;
  opacity: 0;
  scale: 0.3;
  transition: opacity 0.25s, scale 0.35s cubic-bezier(.3, 1.8, .5, 1);
}
.ed-grid .hut .badge { top: 18%; right: -6%; background: #ff4f81; color: #fff; box-shadow: 0 3px 0 #c22d5a; }
.ed-grid .hut .add { top: 18%; right: -6%; background: #fff; color: var(--btn); box-shadow: 0 0 0 3px var(--btn); }
.ed-grid .hut.personal .badge { opacity: 1; scale: 1; }
.ed-grid .hut.needs-photo .add { opacity: 1; scale: 1; animation: breathe 1.6s ease-in-out infinite; }
.ed-grid .hut.needs-photo .inside { background: repeating-linear-gradient(45deg, #fff3d6 0 6px, #ffe6b0 6px 12px); }
.ed-grid .hut:focus-visible .doorway { outline: calc(var(--cw) * 0.03) solid #fff; outline-offset: 2px; }

.ed-bar {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
  z-index: 20;
  display: flex;
  gap: 10px;
  padding: 8px;
  border-radius: 999px;
  translate: -50% 0;
  background: rgba(255, 252, 245, 0.92);
  color: var(--panel-ink);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(10px);
}
.ed-bar[hidden], .ed-bar .btn[hidden] { display: none; }
.ed-bar .btn { white-space: nowrap; }

/* ---------------- 3. Share ---------------- */
.share, .upgrade { max-width: 600px; text-align: center; }
.share-emblem { font-size: 3.6rem; animation: float 3s ease-in-out infinite; }
.share .btn.big { display: block; width: 100%; margin: 6px 0 4px; }
.linkbox { display: flex; gap: 8px; }
.linkbox input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 2px dashed var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--panel-ink);
  font: 700 0.9rem var(--font-body);
}
.share > .btn.ghost { margin-top: 12px; }
.tzrow {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 20px;
  font-weight: 900;
  font-size: 0.9rem;
  text-align: left;
}
.upgrade { text-align: left; }
.upgrade h3 { margin: 0 0 8px; font-family: var(--font-display); font-weight: 900; font-size: 1.5rem; }
.perks { margin: 0 0 16px; padding: 0; list-style: none; display: grid; gap: 8px; font-weight: 700; }
.perks li { padding: 10px 14px; border-radius: 12px; background: var(--soft); }
.paid { display: flex; gap: 14px; align-items: center; }
.paid span { font-size: 2.4rem; }
.paid b { display: block; font-size: 1.1rem; }
.paid small { font-weight: 700; color: var(--muted); }

/* ---------------- Sheets ---------------- */
.sheet { position: fixed; inset: 0; z-index: 38; display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: var(--backdrop); backdrop-filter: blur(6px); animation: fadein 0.25s; }
.sheet-panel {
  position: relative;
  width: min(560px, 100%);
  max-height: 92dvh;
  overflow: auto;
  padding: 0 20px calc(env(safe-area-inset-bottom, 0px) + 18px);
  border-radius: 28px 28px 0 0;
  background: var(--panel);
  color: var(--panel-ink);
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.3);
  animation: sheetup 0.45s cubic-bezier(.2, 1.3, .35, 1);
}
@media (min-width: 700px) {
  .sheet { align-items: center; }
  .sheet-panel { border-radius: 28px; animation-name: popup; }
}
.sheet-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 0 10px;
  background: var(--panel);
}
.sheet-head .kind { flex: 1; font-weight: 800; opacity: 0.7; }
.sheet-body > .label:first-child { margin-top: 4px; }

.current {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border-radius: 18px;
  background: var(--soft);
}
.cur-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  overflow: hidden;
  border-radius: 16px;
  background: #fff;
  font-size: 2.2rem;
}
.cur-icon img { width: 100%; height: 100%; object-fit: cover; }
.cur-text b { display: block; font-size: 1.02rem; line-height: 1.25; }
.cur-text small { display: block; margin-top: 3px; font-weight: 700; color: var(--muted); line-height: 1.35; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 10px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: #fff;
  color: var(--panel-ink);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.actions button span { font-size: 2rem; line-height: 1; }
.actions button b { font-weight: 900; font-size: 0.95rem; }
.actions button.wide { grid-column: span 2; flex-direction: row; flex-wrap: wrap; justify-content: center; column-gap: 10px; row-gap: 2px; }
.actions button.wide small { flex-basis: 100%; font-weight: 700; color: var(--muted); font-size: 0.8rem; }
.actions button:hover { transform: translateY(-3px); border-color: var(--btn); box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08); }
.pick-preset {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-top: 10px;
  padding: 14px 16px;
  border: 2px dashed var(--line);
  border-radius: 18px;
  background: none;
  color: var(--panel-ink);
  font-weight: 900;
  cursor: pointer;
}
.pick-preset span { color: var(--btn); }
.pick-preset:hover { border-color: var(--btn); }
.sheet-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 18px; }
.link { padding: 6px 0; border: 0; background: none; color: var(--muted); font-weight: 800; text-decoration: underline; cursor: pointer; }
.hint { margin: 10px 0 0; font-weight: 700; font-size: 0.88rem; color: var(--muted); }

.photo-edit { display: grid; grid-template-columns: 140px 1fr; gap: 16px; align-items: start; }
.pe-thumb {
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border: 8px solid #fff;
  border-bottom-width: 22px;
  background: #eee;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
  rotate: -2deg;
  display: grid;
  place-items: center;
  font-size: 2.4rem;
}
.pe-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.row-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.btn.small { padding: 8px 12px; font-size: 0.85rem; }
@media (max-width: 420px) { .photo-edit { grid-template-columns: 110px 1fr; } }

.mini-v { margin-bottom: 14px; }
.mini-v .v-main { padding: 14px 16px; }
.mini-v h2 { font-size: 1.4rem; margin: 4px 0 0; }
.idea-chips { justify-content: flex-start; margin-top: 12px; }
.field + .field { margin-top: 12px; }

.preset-list { display: grid; gap: 8px; margin-top: 14px; }
.preset {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--panel-ink);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.preset:hover { border-color: var(--btn); transform: translateX(3px); }
.preset .pe { flex: none; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 12px; background: var(--soft); font-size: 1.6rem; }
.preset b { display: block; font-size: 0.95rem; line-height: 1.25; }
.preset small { display: block; margin-top: 2px; font-weight: 700; color: var(--muted); font-size: 0.8rem; }

.upsell { padding-top: 26px; text-align: center; }
.up-emblem { font-size: 3.4rem; animation: float 2.6s ease-in-out infinite; }
.upsell .perks { text-align: left; }
.upsell .btn.big { width: 100%; }
.upsell .btn.ghost { margin-top: 10px; }

@media (max-width: 560px) {
  .ed-top { padding-left: 12px; padding-right: 12px; gap: 8px; }
  .logo { font-size: 1rem; }
  .ed-steps button span { display: none; }
  .ed-steps button { padding: 6px 11px; }
  .saved { min-width: 0; font-size: 0.72rem; }
  .panel { padding: 22px 18px; border-radius: 24px; }
  .fields { grid-template-columns: 1fr; }
  .theme-cards { grid-template-columns: 1fr 1fr; }
  .theme-card small { display: none; }
}

@keyframes sheetup { from { transform: translateY(100%); } to { transform: none; } }
@keyframes popup { from { transform: translateY(30px) scale(0.94); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* Reward setup: miniature architecture follows the selected 3D world.
   Keep the shared door, photo, badge and keyboard behaviour intact. */
.ed-grid .hut[data-world] .roof::after { pointer-events: none; }
.ed-grid .hut:is([data-world='space'], [data-world='cyber'], [data-world='japan'], [data-world='toys']) .doorway { border-radius: 8% 8% 0 0; }
.ed-grid .hut:is([data-world='space'], [data-world='cyber'], [data-world='japan'], [data-world='toys']) .door-front::before { border-radius: inherit; }
.ed-grid .hut:where(:not([data-world='snow']):not([data-world='summer'])) .ground {
  background: var(--wall2);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.45);
}
.ed-grid .hut:not([data-world='snow']):not([data-world='summer']) .facade::before,
.ed-grid .hut:not([data-world='snow']):not([data-world='summer']) .facade::after {
  content: '';
  position: absolute;
  pointer-events: none;
}

/* Iced biscuits, candy buttons and piped frosting. */
.ed-grid .hut[data-world='gingerbread'] .roof::before {
  background: radial-gradient(circle, #fff8ee 0 18%, transparent 20%) 0 0 / 22% 48%, var(--roof);
}
.ed-grid .hut[data-world='gingerbread'] .roof::after {
  background: #fff8ee;
  clip-path: polygon(50% 0,100% 90%,100% 100%,91% 89%,82% 100%,73% 88%,64% 100%,55% 89%,46% 100%,37% 88%,28% 100%,19% 89%,10% 100%,0 100%,0 90%);
}
.ed-grid .hut[data-world='gingerbread'] .facade {
  background: radial-gradient(circle, #e4ac6e 0 12%, transparent 14%) 0 0 / 16% 17%, var(--wall);
  border: calc(var(--cw) * .025) solid #fff5e8;
  border-radius: 5% 5% 9% 9%;
}
.ed-grid .hut[data-world='gingerbread'] .facade::before {
  inset: 25% 5% 10%;
  background: radial-gradient(circle at 5% 20%,var(--roof) 0 5%,transparent 6%),radial-gradient(circle at 95% 20%,var(--door) 0 5%,transparent 6%),radial-gradient(circle at 5% 75%,var(--door) 0 5%,transparent 6%),radial-gradient(circle at 95% 75%,var(--roof) 0 5%,transparent 6%);
}
.ed-grid .hut[data-world='gingerbread'] .doorway { outline: calc(var(--cw) * .025) solid #fff5e8; }
.ed-grid .hut[data-world='gingerbread'] .ground { background: #fff5e8; }

/* Chunky wooden toy castles with battlements and block seams. */
.ed-grid .hut[data-world='toys'] .roof { top: 8%; height: 24%; left: -3%; right: -3%; }
.ed-grid .hut[data-world='toys'] .roof::before {
  clip-path: polygon(0 0,18% 0,18% 30%,32% 30%,32% 0,48% 0,48% 30%,62% 30%,62% 0,78% 0,78% 30%,84% 30%,84% 0,100% 0,100% 100%,0 100%);
}
.ed-grid .hut[data-world='toys'] .roof::after { background: var(--wall2); clip-path: inset(75% 0 0); }
.ed-grid .hut[data-world='toys'] .facade {
  top: 31%; border: calc(var(--cw) * .025) solid var(--roof);
  background: repeating-linear-gradient(0deg,transparent 0 25%,rgba(0,0,0,.12) 25% 28%),var(--wall);
}
.ed-grid .hut[data-world='toys'] .facade::before {
  inset: 27% 4% 10%; border-left: calc(var(--cw) * .065) solid var(--wall2); border-right: calc(var(--cw) * .065) solid var(--wall2);
}
.ed-grid .hut[data-world='toys'] .ground { border-radius: 12%; background: var(--roof); }

/* Moon-base domes, portholes and silver airlock frames. */
.ed-grid .hut[data-world='space'] .roof { top: 3%; height: 39%; left: -2%; right: -2%; }
.ed-grid .hut[data-world='space'] .roof::before {
  clip-path: none; border-radius: 100% 100% 8% 8% / 100% 100% 8% 8%;
  background: radial-gradient(ellipse at 32% 32%,#ffffffb0,transparent 48%),var(--roof);
  border: calc(var(--cw) * .025) solid #e9edf6;
}
.ed-grid .hut[data-world='space'] .roof::after {
  inset: 58% 24% 17%; clip-path: none; border-radius: 999px; background: #233650;
  box-shadow: inset 0 0 0 calc(var(--cw) * .02) var(--wall),0 1px 0 #ffffff80;
}
.ed-grid .hut[data-world='space'] .facade {
  top: 39%; background: linear-gradient(90deg,#b0bacb,#edf2fa 30%,#d6dfed 70%,#9eaac0);
  border-radius: 0 0 16% 16%; border-bottom: calc(var(--cw) * .05) solid #69758d;
}
.ed-grid .hut[data-world='space'] .facade::before {
  inset: 25% 5% 25%; background: radial-gradient(circle at 6% 50%,var(--wall) 0 5%,#69758d 6% 9%,transparent 10%),radial-gradient(circle at 94% 50%,var(--wall) 0 5%,#69758d 6% 9%,transparent 10%);
}
.ed-grid .hut[data-world='space'] .doorway { left: 25%; right: 25%; height: 70%; outline: calc(var(--cw) * .035) solid #7f8ba3; }
.ed-grid .hut[data-world='space'] .ground { background: #a5a9ba; height: 8%; }
.ed-grid .hut[data-world='space'].open:not(.needs-photo):not(.has-photo) .inside { background: radial-gradient(circle,#e4fdff,var(--wall) 62%,#3d5a7d); }

/* Red-and-green timber workshops with snowy gambrel roofs. */
.ed-grid .hut[data-world='workshop'] .roof::before { clip-path: polygon(32% 0,68% 0,86% 42%,100% 100%,0 100%,14% 42%); }
.ed-grid .hut[data-world='workshop'] .roof::after { background: #fff; clip-path: polygon(32% 0,68% 0,80% 29%,66% 24%,50% 30%,34% 24%,20% 29%); }
.ed-grid .hut[data-world='workshop'] .facade {
  background: repeating-linear-gradient(90deg,transparent 0 17%,#00000015 17% 20%),var(--wall);
  border-left: calc(var(--cw) * .04) solid var(--wall2); border-right: calc(var(--cw) * .04) solid var(--wall2);
}
.ed-grid .hut[data-world='workshop'] .facade::before {
  inset: 23% 4% 14%; background: linear-gradient(90deg,var(--roof) 0 9%,transparent 9% 91%,var(--roof) 91%);
}
.ed-grid .hut[data-world='workshop'] .ground { background: #f4f8ff; }

/* Raised treehouses with shaggy thatch and timber stilts. */
.ed-grid .hut[data-world='jungle'] .roof { left: -12%; right: -12%; }
.ed-grid .hut[data-world='jungle'] .roof::before {
  background: repeating-linear-gradient(75deg,#00000018 0 2px,transparent 2px 7px),var(--roof);
  clip-path: polygon(50% 0,100% 88%,94% 100%,86% 91%,78% 100%,70% 91%,62% 100%,54% 91%,46% 100%,38% 91%,30% 100%,22% 91%,14% 100%,6% 91%,0 88%);
}
.ed-grid .hut[data-world='jungle'] .roof::after { inset: 4% 35% 60%; clip-path: none; border-radius: 100% 0; background: #478a4e; rotate: -20deg; }
.ed-grid .hut[data-world='jungle'] .facade {
  bottom: 10%; background: repeating-linear-gradient(0deg,transparent 0 18%,#78522b80 18% 21%),var(--wall);
  border: calc(var(--cw) * .025) solid #76532e;
}
.ed-grid .hut[data-world='jungle'] .facade::after { left: 9%; right: 9%; top: 100%; height: 21%; border-left: calc(var(--cw) * .065) solid #76532e; border-right: calc(var(--cw) * .065) solid #76532e; }
.ed-grid .hut[data-world='jungle'] .ground { height: 5%; bottom: 7%; border-radius: 5%; background: #76532e; }

/* Pastel machiya: curved eaves, timber frames and split noren curtains. */
.ed-grid .hut[data-world='japan'] .roof { top: 4%; height: 30%; left: -12%; right: -12%; }
.ed-grid .hut[data-world='japan'] .roof::before { clip-path: polygon(50% 0,70% 43%,87% 67%,100% 57%,96% 88%,75% 100%,25% 100%,4% 88%,0 57%,13% 67%,30% 43%); }
.ed-grid .hut[data-world='japan'] .roof::after { background: #ffffff90; clip-path: polygon(50% 0,78% 60%,70% 53%,50% 12%,30% 53%,22% 60%); }
.ed-grid .hut[data-world='japan'] .facade {
  top: 33%; background: linear-gradient(90deg,var(--wall2) 0 5%,transparent 5% 95%,var(--wall2) 95%),var(--wall);
  border-top: calc(var(--cw) * .04) solid var(--wall2); border-bottom: calc(var(--cw) * .045) solid var(--wall2);
}
.ed-grid .hut[data-world='japan'] .facade::before {
  top: 21%; left: 16%; right: 16%; height: 15%; z-index: 2;
  background: linear-gradient(90deg,var(--noren) 0 48%,transparent 48% 52%,var(--noren) 52%); border-radius: 0 0 12% 12%;
}
.ed-grid .hut[data-world='japan'] .facade::after {
  inset: 30% 4% 17%;
  background: repeating-linear-gradient(0deg,transparent 0 19%,var(--wall2) 19% 23%) left / 12% 100% no-repeat, repeating-linear-gradient(0deg,transparent 0 19%,var(--wall2) 19% 23%) right / 12% 100% no-repeat;
  border-left: calc(var(--cw) * .065) solid var(--wall2); border-right: calc(var(--cw) * .065) solid var(--wall2); z-index: 0;
}
.ed-grid .hut[data-world='japan'] .ground { height: 6%; background: #d8cbdc; }

/* Stacked capsule apartments, holo signs and restrained neon edges. */
.ed-grid .hut[data-world='cyber'] .roof { top: 5%; height: 29%; left: 12%; right: -2%; }
.ed-grid .hut[data-world='cyber'] .roof::before {
  clip-path: none; border-radius: 7% 7% 0 0; background: var(--wall2); border-top: calc(var(--cw) * .025) solid var(--roof);
}
.ed-grid .hut[data-world='cyber'] .roof::after { inset: 39% 17% 21%; clip-path: none; background: var(--roof); box-shadow: 0 0 5px color-mix(in srgb,var(--roof) 40%,transparent); }
.ed-grid .hut[data-world='cyber'] .facade {
  top: 33%; background: repeating-linear-gradient(0deg,transparent 0 23%,#00000020 23% 25%),var(--wall);
  border: calc(var(--cw) * .018) solid var(--roof); border-radius: 3%; box-shadow: 0 0 5px color-mix(in srgb,var(--roof) 30%,transparent);
}
.ed-grid .hut[data-world='cyber'] .facade::before { left: -7%; top: 16%; width: 9%; height: 42%; background: repeating-linear-gradient(0deg,var(--roof) 0 15%,var(--door) 15% 23%); border: 2px solid var(--door); }
.ed-grid .hut[data-world='cyber'] .doorway { outline: calc(var(--cw) * .02) solid var(--roof); }
.ed-grid .hut[data-world='cyber'] .plaque { background: var(--door); color: var(--door-ink); border: 1px solid var(--roof); }
.ed-grid .hut[data-world='cyber'] .ground { height: 5%; bottom: -2%; border-radius: 10%; background: var(--door); border-top: 2px solid var(--roof); }
.ed-grid .hut[data-world='cyber'].open:not(.needs-photo):not(.has-photo) .inside { background: radial-gradient(circle,#e4efff,var(--wall2) 60%,var(--door)); }
.ed-grid .hut:is([data-world='space'],[data-world='cyber']) .doorway::after { background: radial-gradient(ellipse at 50% 70%,color-mix(in srgb,var(--roof) 35%,transparent),transparent 70%); }

/* Compact world picker: every world is discoverable beside the live preview. */
.world-picker { margin-top: 18px; }
.world-picker h2 { margin: 0 0 8px; font-size: 1.15rem; font-weight: 900; }
.world-pass-summary { margin: 0 0 12px; padding: 9px 12px; border: 1px solid #d6af61; border-radius: 12px; background: #292047; color: #fff8e9; font-size: .78rem; line-height: 1.4; }
.world-pass-summary strong { color: #ffdc96; }
.world-pass-summary span { display: block; }
.world-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.world-grid .theme-card { min-width: 0; padding: 5px 5px 7px; border-width: 2px; border-radius: 13px; gap: 3px; }
.world-grid .theme-card svg { aspect-ratio: 2 / 1; object-fit: cover; margin: 0; border-radius: 8px; }
.world-grid .theme-card b { padding: 0 2px; font-size: .8rem; line-height: 1.2; }
.world-grid .theme-card.on { box-shadow: 0 0 0 2px color-mix(in srgb, var(--btn) 20%, transparent); }
.world-grid .theme-card:focus-visible { outline: 3px solid var(--btn); outline-offset: 2px; }
.world-access { align-self: flex-start; padding: 2px 6px; border-radius: 999px; font-size: .62rem; font-weight: 900; }
.free-access { background: #e6f5eb; color: #276044; }
.paid-access { background: #fff3c4; color: #7a5a00; }
.selected-world { min-height: 2.7em; margin: 10px 0 0; font-size: .8rem; line-height: 1.35; color: var(--muted); }
.world-picker-footer { position: sticky; bottom: 0; padding: 12px 0 0; background: #fffcf5; border-top: 1px solid var(--line); }
.world-picker-footer .btn { width: 100%; }
.world-picker-footer .fine { margin-top: 7px; font-size: .7rem; }
@media (max-width: 560px) {
  .world-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .world-grid .theme-card b { font-size: .85rem; }
  .world-picker-footer { padding-bottom: env(safe-area-inset-bottom, 0px); }
}

.account-panel { max-width: 940px; margin-top: 24px; }
.account-panel p { color: var(--muted); line-height: 1.5; }
.account-panel label { display: block; font-weight: 900; margin-bottom: 8px; }
.account-email-row { display: flex; gap: 10px; }
.account-email-row input { min-width: 0; flex: 1; padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px; font: inherit; color: var(--panel-ink); background: #fff; }
.account-email-row input:focus-visible { outline: 3px solid var(--btn); outline-offset: 2px; }
.account-email-row .btn { flex-shrink: 0; }
#accountMessage:empty { display: none; }
#accountMessage[role='alert'] { color: #a3213b; }
.account-calendars { margin-top: 18px; }
.account-calendars summary { cursor: pointer; font-weight: 900; }
#accountCalendars { display: grid; gap: 8px; margin-top: 12px; }
#accountCalendars a { color: var(--btn); font-weight: 800; padding: 8px 0; }
.auth-result { max-width: 540px; margin-top: 12vh; }
@media (max-width:560px) { .account-email-row { flex-direction: column; } .account-panel .ed-h2 { font-size: 1.5rem; } }

/* The world picker floats on the left; rewards and sharing use the centered layout. */
@media (min-width: 960px) {
  body.editor[data-editor-step="start"] {
    --editor-width: min(520px, 44vw);
    --editor-inset: max(24px, 3vw);
  }
  .editor[data-editor-step="start"] .ed-main {
    width: var(--editor-width);
    margin-left: var(--editor-inset);
    margin-right: auto;
    padding: 12px 0 112px;
  }
  .editor[data-editor-step="start"] .hero { max-width: none; margin-top: 0; padding: 18px 20px; }
  .editor[data-editor-step="start"] .account-panel { margin-top: 12px; }
  .editor[data-editor-step="start"] .ed-h1 { font-size: 2.1rem; margin-bottom: 14px; }
  .editor[data-editor-step="start"] .fields input { padding: 9px 12px; }
  .editor[data-editor-step="start"] .ed-main { padding-top: 12px; padding-bottom: 24px; }
  .editor[data-editor-step="start"] .account-email-row { flex-direction: column; }

}

/* Short desktop windows still show all nine options before scrolling. */
@media (min-width: 960px) and (max-height: 850px) {
  .editor[data-editor-step="start"] .hero { padding: 14px 20px; }
  .editor[data-editor-step="start"] .ed-h1 { margin-bottom: 10px; }
  .editor[data-editor-step="start"] .fields input { padding: 7px 12px; }
  .editor[data-editor-step="start"] .world-picker { margin-top: 12px; }
  .editor[data-editor-step="start"] .world-picker h2 { margin-bottom: 5px; }
  .editor[data-editor-step="start"] .world-pass-summary { padding: 6px 10px; margin-bottom: 8px; }
  .editor[data-editor-step="start"] .world-grid .theme-card svg { height: 42px; }
  .editor[data-editor-step="start"] .selected-world { margin-top: 7px; }
  .editor[data-editor-step="start"] .world-picker-footer { padding-top: 8px; }
  .editor[data-editor-step="start"] .world-picker-footer .btn { padding: 11px 20px; font-size: 1.1rem; }
}

.pass-notice { margin: 8px 0; font-size: .78rem; line-height: 1.35; color: var(--muted); }
.pass-notice[hidden] { display: none; }
.world-preview-button { padding: 7px 12px; font-size: .8rem; }
.world-preview-dialog { position: fixed; inset: 0; width: 100%; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #0b1638; color: #fff; }
.world-preview-dialog[open] { display: flex; flex-direction: column; }
.world-preview-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: max(10px, env(safe-area-inset-top)) 14px 10px; }
.world-preview-head h2 { margin: 0; font-size: 1rem; }
.world-preview-head .btn { padding: 10px 12px; font-size: .85rem; }
.world-preview-dialog iframe { flex: 1; min-height: 0; width: 100%; border: 0; }
body:has(.world-preview-dialog[open]) { overflow: hidden; }
@media (min-width: 960px) and (max-height: 850px) {
  .editor[data-editor-step="start"] .world-grid .theme-card { gap: 1px; padding-bottom: 4px; }
  .editor[data-editor-step="start"] .world-grid .theme-card svg { height: 32px; }
  .editor[data-editor-step="start"] .selected-world { min-height: 0; margin-top: 6px; font-size: .72rem; }
  .editor[data-editor-step="start"] .pass-notice { margin: 5px 0; font-size: .7rem; }
  .editor[data-editor-step="start"] .world-preview-button { padding: 5px 10px; }
}

.ed-top .language-select { flex-shrink: 0; }
@media (max-width: 600px) {
  .ed-top { flex-wrap: wrap; gap: 8px; }
  .ed-top .language-select { max-width: 110px; margin-left: auto; }
}
