/* Arches — touch-first dark glass UI */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
:root {
  --bg: #0b0f14;
  --glass: rgba(16, 22, 30, 0.72);
  --glass-hi: rgba(30, 40, 52, 0.85);
  --line: rgba(255, 255, 255, 0.09);
  --text: #e8eef4;
  --dim: #93a4b4;
  --accent: #4db8ff;
  --accent2: #ffb347;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
#app, #gl, #overlay { position: fixed; inset: 0; }
#gl { touch-action: none; }
#overlay { pointer-events: none; }

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
button:active { transform: scale(0.96); }
a { color: var(--accent); }

/* top bar */
#topbar {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding:
    calc(10px + env(safe-area-inset-top, 0px))
    calc(14px + env(safe-area-inset-right, 0px))
    10px
    calc(14px + env(safe-area-inset-left, 0px));
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }
.brand {
  font-weight: 800; letter-spacing: 0.22em; font-size: 15px;
  text-shadow: 0 2px 12px rgba(0,0,0,0.6);
  display: flex; align-items: center; gap: 7px;
  min-width: 0; overflow: hidden; white-space: nowrap;
}
.brand-mark { font-size: 19px; flex: 0 0 auto; }
/* The actions must never be the thing that gets squeezed offscreen — the
   settings button is the last child, so any topbar overflow hides it first. */
.top-actions { display: flex; gap: 8px; flex: 0 0 auto; }

.chip {
  background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-radius: 999px; padding: 10px 14px; font-size: 14px; font-weight: 600;
  min-height: 42px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.35);
}
.chip.primary { background: linear-gradient(135deg, #1c76c2, #15537e); border-color: rgba(120,200,255,0.35); }
.chip.on { background: var(--accent); color: #052033; border-color: transparent; }
.chip.mini { padding: 6px 11px; min-height: 30px; font-size: 12.5px; font-weight: 500; }
.chip.dim, .tool.dim { opacity: 0.4; }

/* left rail */
#rail {
  /* The rail is ~511px tall on phones. Centring it on the whole viewport ran
     its bottom under the dock and behind toasts on anything shorter than a
     Pro Max, so instead pin it to the band between the topbar and the dock
     and centre it in there — falling back to scrolling if even that is tight. */
  --rail-top: calc(58px + env(safe-area-inset-top, 0px));
  --rail-bottom: calc(124px + var(--safe-b));
  position: fixed; left: calc(10px + env(safe-area-inset-left, 0px));
  top: var(--rail-top); bottom: var(--rail-bottom);
  height: fit-content; margin-block: auto;
  max-height: calc(100vh - var(--rail-top) - var(--rail-bottom));
  max-height: calc(100dvh - var(--rail-top) - var(--rail-bottom));
  /* Scrollbar deliberately left visible: on the few viewports where the rail
     still overflows (SE1 portrait, landscape) it is the only affordance that
     the remaining tools are reachable. Taller screens never overflow. */
  overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 6px;
  background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-radius: 20px; padding: 8px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  z-index: 5;
}
.tool {
  width: 58px; min-height: 54px; border-radius: 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 20px; gap: 2px;
}
.tool span { font-size: 10px; font-weight: 600; color: var(--dim); letter-spacing: 0.02em; }
.tool.active { background: rgba(77, 184, 255, 0.18); box-shadow: inset 0 0 0 1.5px var(--accent); }
.tool.active span { color: var(--accent); }
.tool.wand { background: rgba(255, 179, 71, 0.1); }
.rail-sep { height: 1px; background: var(--line); margin: 3px 6px; }

/* contextual tool options */
#toolopts {
  position: fixed; left: 84px; top: 50%; transform: translateY(-50%);
  background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-radius: var(--radius); padding: 13px; width: 250px;
  max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px);
  overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  z-index: 5;
}
#toolopts[data-mode="look"] { width: min(360px, calc(100vw - 116px)); }
.opts { display: flex; flex-direction: column; gap: 11px; }
.chiprow { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.sliderrow { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--dim); font-weight: 600; }
.sliderrow b { color: var(--text); }
.hint { font-size: 12.5px; color: var(--dim); line-height: 1.45; }

/* Mode sheet header: which mode you're in, and the way out of it. */
.mode-head {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding-bottom: 4px;
  background: linear-gradient(var(--glass), var(--glass));
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.mode-head .mode-name { font-weight: 700; font-size: 14px; letter-spacing: 0.01em; }
.mode-head .chip { min-height: 40px; }
#viewBtn {
  position: fixed; z-index: 6; left: 50%; transform: translateX(-50%);
  bottom: calc(124px + var(--safe-b));
}

/* selection info */
#selInfo {
  position: fixed; top: calc(64px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  background: rgba(28, 118, 194, 0.28); border: 1px solid rgba(120, 200, 255, 0.4);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-radius: 999px; padding: 8px 10px 8px 16px; font-size: 13.5px;
  z-index: 5;
}

/* describe bar */
#describeBar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(128px + var(--safe-b));
  width: min(620px, calc(100vw - 24px));
  display: flex; flex-direction: column; gap: 8px;
  z-index: 6;
}
#descChips { display: flex; gap: 7px; flex-wrap: wrap; justify-content: center; }
#descChips .chip { background: var(--glass); }
.descrow {
  display: flex; gap: 8px; align-items: center;
  background: var(--glass-hi); border: 1px solid var(--line);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-radius: 999px; padding: 8px;
  box-shadow: 0 10px 36px rgba(0,0,0,0.5);
}
#descInput {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: 16px; padding: 8px 8px 8px 14px;
  user-select: text; -webkit-user-select: text;
}
#descInput::placeholder { color: var(--dim); }
.round {
  width: 46px; height: 46px; border-radius: 50%; font-size: 19px;
  background: rgba(255,255,255,0.08); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.round.go { background: linear-gradient(135deg, #f7b955, #e08830); }
.round.on { background: var(--accent); }
.round.rec { background: #e0483a; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(224, 72, 58, 0.25); } }

/* time dock */
#dock {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(12px + var(--safe-b));
  width: min(620px, calc(100vw - 24px));
  background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-radius: 22px; padding: 10px 14px;
  display: flex; flex-direction: column; gap: 4px;
  box-shadow: 0 10px 36px rgba(0,0,0,0.45);
  z-index: 5;
}
.dockrow { display: flex; align-items: center; gap: 11px; }
.dock-ico { font-size: 17px; width: 22px; text-align: center; }
.dock-label { font-size: 12.5px; font-weight: 700; color: var(--dim); width: 108px; text-align: right; white-space: nowrap; }
.dockrow .round { width: 38px; height: 38px; font-size: 14px; }

/* range inputs */
input[type="range"] {
  flex: 1; -webkit-appearance: none; appearance: none; height: 34px; background: none;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, rgba(255,255,255,0.22), rgba(255,255,255,0.1));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; margin-top: -10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 0 0 4px rgba(77,184,255,0.25);
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: rgba(255,255,255,0.16); }
input[type="range"]::-moz-range-thumb {
  width: 24px; height: 24px; border-radius: 50%; background: #fff; border: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 0 0 4px rgba(77,184,255,0.25);
}

/* sheets */
#sheet {
  position: fixed; inset: 0; z-index: 20;
  /* A live full-screen backdrop blur forces Mobile Safari to composite the
     WebGPU canvas through an extra filter while the panel moves. The panel is
     already opaque; a darker scrim keeps the same visual separation without
     rereading and blurring every Ultra frame. */
  background: rgba(4, 8, 12, 0.78);
  display: flex; align-items: flex-end; justify-content: center;
}
.panel {
  background: #121a23; border: 1px solid var(--line); border-bottom: none;
  border-radius: 24px 24px 0 0;
  width: min(560px, 100vw);
  max-height: calc(88vh - var(--safe-b));
  overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 18px 20px calc(26px + var(--safe-b));
  animation: rise 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
  contain: layout paint;
}
.panel.wide { width: min(760px, 100vw); }
@keyframes rise { from { transform: translate3d(0, 60px, 0); opacity: 0; } }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.panel-head h2 { font-size: 19px; }
.panel-head .x { font-size: 16px; padding: 10px 12px; color: var(--dim); }
.panel h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--dim); margin: 18px 0 9px; }
.stack { display: flex; flex-direction: column; }
.stack > .hint { line-height: 1.5; }

/* gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 11px; }
.card {
  background: rgba(255,255,255,0.045); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px; text-align: left; position: relative;
  display: flex; flex-direction: column; gap: 6px;
  transition: border-color 0.15s;
}
.card:hover { border-color: var(--accent); }
.thumb { width: 100%; aspect-ratio: 1; border-radius: 10px; background: #0a1520; }
.card-emoji { position: absolute; top: 16px; right: 16px; font-size: 22px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.6)); }
.card-name { font-weight: 700; font-size: 14.5px; }
.card-desc { font-size: 11.8px; color: var(--dim); line-height: 1.35; }
.gallery-foot { display: flex; justify-content: center; margin-top: 15px; }

.big-btn {
  background: linear-gradient(135deg, #1c76c2, #15537e); border: 1px solid rgba(120,200,255,0.35);
  border-radius: 14px; padding: 14px 22px; font-size: 15.5px; font-weight: 700;
  min-height: 52px; margin-top: 8px;
}
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.export-btn {
  background: rgba(255,255,255,0.05); border: 1px solid var(--line); border-radius: 13px;
  padding: 12px 14px; text-align: left; display: flex; flex-direction: column; gap: 3px;
  min-height: 60px;
}
.export-btn b { font-size: 14px; }
.export-btn span { font-size: 11.5px; color: var(--dim); }
.sel, .text {
  background: rgba(255,255,255,0.06); border: 1px solid var(--line); border-radius: 11px;
  color: var(--text); font: inherit; padding: 12px 13px; margin: 4px 0;
  outline: none; user-select: text; -webkit-user-select: text;
}
.sel { appearance: auto; }

/* veil */
#veil {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(6, 10, 15, 0.55);
  backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center;
}
.veil-inner { width: min(340px, 76vw); text-align: center; }
.veil-title { font-size: 15.5px; font-weight: 700; margin-bottom: 14px; text-shadow: 0 2px 10px rgba(0,0,0,0.6); }
.veil-track { height: 8px; border-radius: 4px; background: rgba(255,255,255,0.12); overflow: hidden; }
.veil-bar {
  height: 100%; width: 5%; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), #7fd0ff);
  transition: width 0.18s ease;
}

/* toasts */
#toasts {
  position: fixed; bottom: calc(150px + var(--safe-b)); left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 50; pointer-events: none; width: min(520px, calc(100vw - 30px));
}
.toast {
  background: var(--glass-hi); border: 1px solid var(--line);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-radius: 13px; padding: 11px 17px; font-size: 13.5px; line-height: 1.4;
  opacity: 0; transform: translateY(8px); transition: all 0.3s ease;
  box-shadow: 0 8px 26px rgba(0,0,0,0.5); text-align: center;
}
.toast.show { opacity: 1; transform: none; }

/* walk-mode joystick */
#joystick {
  position: fixed; width: 110px; height: 110px; border-radius: 50%;
  background: rgba(255,255,255,0.07); border: 1.5px solid var(--line);
  z-index: 30; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
}
#joystick div {
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(255,255,255,0.35);
}
#walkHint {
  position: fixed; top: calc(64px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%);
  background: var(--glass); border: 1px solid var(--line); border-radius: 999px;
  padding: 9px 16px; font-size: 13px; z-index: 6;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  display: flex; align-items: center; gap: 12px;
}
.walk-tip { font-size: 12px; color: var(--dim); }
/* 44px-class target: the old exit was a 24px-wide inline <b>, which is a hard
   thing to hit with a thumb when it is the only way out of walk mode. */
#walkExitBtn { min-height: 40px; flex: 0 0 auto; }
.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.preset-grid .chip { justify-content: flex-start; text-align: left; }
.latlon-row { display: flex; gap: 8px; align-items: center; }
.latlon-row input { flex: 1; min-width: 0; }
.import-card {
  background: rgba(255,255,255,0.045); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 17px; margin: 9px 0; display: flex; flex-direction: column; gap: 8px;
}
.import-card b { font-size: 15px; }
.import-card .hint { margin: 0; }
.chooser-thumb { max-width: 220px; border-radius: 12px; border: 1px solid var(--line); align-self: center; }

/* small screens */
@media (max-width: 700px) {
  .brand { letter-spacing: 0.14em; font-size: 13px; }
  .tool { width: 50px; min-height: 48px; font-size: 17px; }
  .tool span { font-size: 9px; }
  /* Phone: the tool panel used to float over the middle of the terrain, so you
     could not see the ground you were eroding. Dock it to the bottom edge
     instead, and while a mode is open give it the whole screen to itself by
     dropping the rail and the time dock. */
  #toolopts {
    left: 10px; right: 10px; width: auto;
    top: auto; bottom: calc(10px + var(--safe-b)); transform: none;
    max-height: none; overflow: visible;
    border-radius: 18px; padding: 7px;
  }
  #toolopts[data-mode="look"] { width: auto; }
  .modebar { display: flex; flex-direction: column; gap: 8px; }
  .mrow { display: flex; align-items: center; gap: 5px; }
  /* Only the tool strip scrolls. ✓ and ✕ live outside it, because with the rail
     hidden they are the only way out and must never scroll off the end. */
  .mscroll {
    display: flex; align-items: center; gap: 5px;
    flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none;
  }
  .mscroll::-webkit-scrollbar { display: none; }
  /* 44px is the touch-target floor; the sizing below keeps Erode's seven
     buttons (five tools + ✕ + ✓) inside a 375px screen without clipping. */
  .mbtn {
    flex: 0 0 auto; width: 44px; height: 44px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center; font-size: 19px;
    background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line);
  }
  .mbtn.on { background: var(--accent); color: #052033; border-color: transparent; }
  .mbtn.go { background: var(--accent); color: #052033; border-color: transparent; font-size: 21px; }
  .mbtn.warn { color: #ff9b9b; }
  .mstat { flex: 0 0 auto; font-size: 12px; color: var(--dim); font-weight: 600; padding: 0 2px; }
  .paramrow { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--dim); font-weight: 600; }
  .paramrow input[type="range"] { flex: 1 1 auto; min-width: 0; }
  body.mode-open #rail,
  body.mode-open #dock,
  body.walk-open #rail,
  body.walk-open #dock { display: none; }
  /* The rail is gone, so toasts can span the width again — but they must clear
     the bottom sheet, which is exactly where they used to sit. Move them up
     under the topbar, into the space the hidden rail freed. */
  body.mode-open #toasts,
  body.walk-open #toasts {
    left: calc(15px + env(safe-area-inset-left, 0px));
    top: calc(70px + env(safe-area-inset-top, 0px));
    bottom: auto;
  }
  /* Walk gets the same bottom-bar treatment as the tool modes. */
  #walkHint {
    top: auto; bottom: calc(10px + var(--safe-b));
    left: 10px; right: 10px; transform: none;
    border-radius: 20px; padding: 10px 12px;
    flex-wrap: wrap; justify-content: space-between;
  }
  /* The 👁 View pill sits at 124px; toasts defaulted to 150px and the world-name
     toast landed straight on top of it on first load. Clear the pill. */
  #toasts { bottom: calc(180px + var(--safe-b)); }
  .dock-label { width: 88px; font-size: 11px; }
  #describeBar { bottom: calc(118px + var(--safe-b)); }
  .btn-grid { grid-template-columns: 1fr; }
}

/* Phones: the five action chips plus the wordmark are wider than a 390px
   viewport, which pushed ⚙️ Settings off the right edge. Drop the wordmark
   first, then the "Worlds" label, so the chips always fit. */
@media (max-width: 480px) {
  .brand-text { display: none; }
  #topbar .chip { padding: 9px 11px; }
}
@media (max-width: 380px) {
  #topbar .chip-label { display: none; }
  .top-actions { gap: 6px; }
}

/* Toasts span the width and sit at z-50, so on phones they painted straight
   over the rail's Undo/Redo/Reroll. Start them to the right of the rail. */
@media (max-width: 700px) {
  #toasts {
    left: calc(88px + env(safe-area-inset-left, 0px));
    right: calc(15px + env(safe-area-inset-right, 0px));
    transform: none; width: auto;
  }
}

/* Short phones (SE, older 4.7"/5.5") don't have room for the full-size rail
   between the topbar and the dock — tighten it rather than let it scroll. */
@media (max-height: 750px) {
  #rail { gap: 4px; }
  .tool { min-height: 44px; }
  .tool span { font-size: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* -------------------------------------------------------------------------
   Bryce Tribute UI

   An optional, code-drawn homage to Kai Krause's immersive interface
   language: full-screen "rooms", unfolding palettes, sculpted controls and
   mouse-over contrast. No original Bryce artwork or interface assets are used.
   The modern touch UI above remains the default.
   ------------------------------------------------------------------------- */
#bryceChrome { display: none; }

html[data-ui="bryce"] {
  --bg: #333839;
  --glass: rgba(164, 166, 159, 0.96);
  --glass-hi: rgba(189, 190, 181, 0.98);
  --line: rgba(23, 29, 30, 0.72);
  --text: #151a1b;
  --dim: #3d4749;
  --accent: #39a8c0;
  --accent2: #f0ad55;
  --radius: 7px;
}

html[data-ui="bryce"] body {
  background: #555c5c;
  font-family: "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
}

html[data-ui="bryce"] #bryceChrome {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  color: #171b1c;
  font-family: "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  letter-spacing: 0.06em;
}

html[data-ui="bryce"] .bryce-menubar {
  pointer-events: auto;
  position: absolute;
  inset: 0 0 auto;
  height: 26px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 10px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.7), transparent 42%),
    linear-gradient(90deg, #a8aaa4, #767d7b 58%, #b7b7ad);
  border-bottom: 1px solid #252b2c;
  box-shadow: inset 0 -1px rgba(255,255,255,0.42), 0 2px 7px rgba(0,0,0,0.42);
  font-size: 9px;
  font-weight: 800;
  text-shadow: 0 1px rgba(255,255,255,0.48);
}
.bryce-wordmark {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-right: 5px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.2em;
}
.bryce-wordmark i {
  font-size: 8px;
  font-style: normal;
  letter-spacing: 0.08em;
  color: #334144;
}
.bryce-menuitem { opacity: 0.72; }
#bryceExit {
  margin-left: auto;
  min-height: 18px;
  padding: 1px 8px 0;
  border: 1px solid #42494a;
  border-radius: 10px;
  background: linear-gradient(#c9cac1, #747b79);
  box-shadow: inset 0 1px #fff, 0 1px 2px rgba(0,0,0,0.5);
  color: #222829;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

html[data-ui="bryce"] .bryce-roombar {
  pointer-events: auto;
  position: absolute;
  top: 32px;
  left: 92px;
  display: flex;
  gap: 5px;
  padding: 5px 6px;
  border: 1px solid #242a2b;
  border-radius: 8px 8px 17px 8px;
  background:
    linear-gradient(145deg, rgba(255,255,255,0.7), transparent 36%),
    linear-gradient(120deg, #b4b4aa, #707775);
  box-shadow: inset 1px 1px #e2e1d6, inset -1px -1px #464d4c, 0 5px 14px rgba(0,0,0,0.48);
}
.bryce-room {
  position: relative;
  width: 76px;
  height: 52px;
  border: 1px solid #3d4445;
  border-radius: 5px 14px 5px 12px;
  background: linear-gradient(145deg, #c4c5bc, #777d7a 70%);
  box-shadow: inset 1px 1px rgba(255,255,255,0.82), inset -2px -2px rgba(36,43,44,0.38), 0 1px 2px rgba(0,0,0,0.7);
  color: #1d2526;
  text-shadow: 0 1px rgba(255,255,255,0.52);
}
.bryce-room:hover,
.bryce-room:focus-visible { filter: brightness(1.13); outline: none; }
.bryce-room.active {
  background: linear-gradient(145deg, #b8e0e3, #4d8994 68%, #2c5962);
  box-shadow: inset 2px 2px rgba(255,255,255,0.65), inset -2px -2px rgba(14,55,64,0.54), 0 0 0 1px #9ee6ef;
}
.bryce-room b {
  position: absolute;
  left: 5px;
  right: 4px;
  bottom: 4px;
  font-size: 8px;
  line-height: 1;
  text-align: right;
  letter-spacing: 0.08em;
}
.bryce-orb {
  position: absolute;
  top: 5px;
  left: 8px;
  width: 31px;
  height: 31px;
  border: 1px solid #303738;
  border-radius: 50%;
  box-shadow: inset -7px -8px 9px rgba(4,11,12,0.6), inset 4px 3px 5px rgba(255,255,255,0.78), 0 2px 3px rgba(0,0,0,0.5);
}
.terrain-orb {
  background:
    radial-gradient(ellipse at 39% 70%, #243b30 0 9%, transparent 10%),
    conic-gradient(from 28deg at 48% 58%, #53735a, #1f4437, #779171, #354f40, #53735a);
}
.edit-orb {
  background:
    linear-gradient(140deg, transparent 0 43%, rgba(255,255,255,0.72) 45% 50%, transparent 52%),
    radial-gradient(circle at 40% 35%, #d8d8cc, #66706e 53%, #263033 76%);
}
.sky-orb {
  background:
    radial-gradient(ellipse at 36% 64%, rgba(255,255,255,0.94) 0 13%, transparent 15%),
    radial-gradient(ellipse at 63% 58%, rgba(236,246,239,0.86) 0 18%, transparent 20%),
    linear-gradient(#5fbad1 0 50%, #d7c68b 52%, #3d6c76 55%);
}
.render-orb {
  background:
    radial-gradient(circle at 37% 33%, #fff9c7 0 8%, #efb750 10% 24%, transparent 26%),
    radial-gradient(circle at 50% 50%, #7c7562, #252b2d 72%);
}

html[data-ui="bryce"] .bryce-viewpalette {
  pointer-events: auto;
  position: absolute;
  top: 106px;
  right: 9px;
  width: 78px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 9px 8px 8px;
  border: 1px solid #252b2c;
  border-radius: 28px 7px 16px 7px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.68), transparent 34%),
    linear-gradient(150deg, #b8b8ae, #6d7573);
  box-shadow: inset 1px 1px #e0dfd4, inset -1px -1px #414948, 0 6px 15px rgba(0,0,0,0.48);
}
.bryce-palette-title { font-size: 8px; font-weight: 900; }
.bryce-trackball {
  position: relative;
  width: 48px;
  height: 48px;
  border: 1px solid #2e3738;
  border-radius: 50%;
  background:
    radial-gradient(circle at 33% 28%, #eff2e9 0 4%, transparent 7%),
    radial-gradient(circle at 38% 36%, #9fd2d5, #3c7079 45%, #182426 76%);
  box-shadow: inset -5px -7px 9px rgba(0,0,0,0.68), 0 2px 4px rgba(0,0,0,0.68);
}
.bryce-trackball::before,
.bryce-trackball::after {
  content: "";
  position: absolute;
  left: 5px;
  right: 5px;
  top: 50%;
  height: 1px;
  background: rgba(219,244,244,0.45);
  border-radius: 50%;
}
.bryce-trackball::after { transform: rotate(90deg); }
.bryce-trackball i {
  position: absolute;
  inset: 9px 18px;
  border: 1px solid rgba(229,250,250,0.5);
  border-radius: 50%;
}
.bryce-viewgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.bryce-viewgrid button,
.bryce-preview {
  border: 1px solid #363d3e;
  background: linear-gradient(145deg, #c6c6bc, #69716f);
  box-shadow: inset 1px 1px rgba(255,255,255,0.75), 0 1px 2px rgba(0,0,0,0.6);
  color: #1a2223;
  font-size: 8px;
  font-weight: 900;
}
.bryce-viewgrid button { width: 26px; height: 24px; border-radius: 10px 4px; }
.bryce-preview { width: 60px; min-height: 27px; border-radius: 5px 11px; letter-spacing: 0.03em; }

html[data-ui="bryce"] .bryce-status {
  position: absolute;
  left: 9px;
  bottom: 8px;
  width: 142px;
  min-height: 25px;
  display: grid;
  grid-template-columns: 9px 1fr;
  align-items: center;
  padding: 4px 7px;
  border: 1px solid #252b2c;
  border-radius: 4px 14px 4px 8px;
  background: linear-gradient(145deg, #b9bab0, #69716f);
  box-shadow: inset 1px 1px rgba(255,255,255,0.7), 0 2px 5px rgba(0,0,0,0.55);
  font-size: 7px;
  font-weight: 800;
  line-height: 1.25;
}
.bryce-status > :last-child { grid-column: 2; opacity: 0.65; }
.bryce-led {
  grid-row: 1 / 3;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #3fd0c8;
  box-shadow: inset 1px 1px #d7ffff, 0 0 5px #49dcd2;
}

/* Existing Arches controls become the functional lower palettes. The sharply
   modelled surfaces and restrained cyan/amber indicators carry the homage;
   controls stay large enough for modern touch and pointer input. */
html[data-ui="bryce"] #topbar {
  top: 28px;
  justify-content: flex-end;
  padding: 6px 9px;
  z-index: 9;
}
html[data-ui="bryce"] .top-actions { gap: 5px; }
html[data-ui="bryce"] .chip {
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid #343b3c;
  border-radius: 6px 13px 6px 11px;
  background:
    linear-gradient(145deg, rgba(255,255,255,0.75), transparent 38%),
    linear-gradient(135deg, #bfc0b7, #6e7673);
  box-shadow: inset 1px 1px rgba(255,255,255,0.72), inset -1px -1px rgba(29,37,38,0.35), 0 2px 5px rgba(0,0,0,0.48);
  color: #151c1d;
  text-shadow: 0 1px rgba(255,255,255,0.48);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
html[data-ui="bryce"] .chip.primary {
  background: linear-gradient(145deg, #bfe9e8, #5b9ca7 58%, #376c76);
  border-color: #2a4f56;
}
html[data-ui="bryce"] .chip.on {
  background: linear-gradient(145deg, #b7edf0, #3996a8 62%, #276373);
  color: #0f262b;
  border-color: #174854;
}
html[data-ui="bryce"] #rail {
  --rail-top: 98px;
  --rail-bottom: 102px;
  left: 8px;
  gap: 3px;
  padding: 8px 6px;
  border: 1px solid #252b2c;
  border-radius: 30px 7px 19px 7px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.7), transparent 29%),
    linear-gradient(160deg, #b6b7ae, #68716f);
  box-shadow: inset 1px 1px #e2e1d6, inset -1px -1px #3e4746, 0 7px 18px rgba(0,0,0,0.52);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  z-index: 9;
}
html[data-ui="bryce"] .tool {
  width: 54px;
  min-height: 50px;
  border: 1px solid transparent;
  border-radius: 50% 12px 50% 12px;
  color: #171d1e;
  filter: saturate(0.78);
}
html[data-ui="bryce"] .tool:hover { background: rgba(230,235,226,0.28); border-color: rgba(47,57,58,0.46); }
html[data-ui="bryce"] .tool.active {
  background: radial-gradient(circle at 37% 30%, #cef1ee, #5b9ca6 55%, #315d65 78%);
  border-color: #285a64;
  box-shadow: inset 2px 2px rgba(255,255,255,0.65), inset -3px -4px rgba(16,54,61,0.48), 0 1px 3px rgba(0,0,0,0.5);
}
html[data-ui="bryce"] .tool span { color: #273031; text-shadow: 0 1px rgba(255,255,255,0.45); }
html[data-ui="bryce"] .tool.active span { color: #10272c; }
html[data-ui="bryce"] .rail-sep { background: #48504f; box-shadow: 0 1px rgba(255,255,255,0.36); }
html[data-ui="bryce"] #toolopts {
  left: 74px;
  top: 105px;
  transform: none;
  border: 1px solid #252b2c;
  border-radius: 5px 19px 5px 11px;
  background: linear-gradient(145deg, #b8b9b0, #707875);
  box-shadow: inset 1px 1px #e3e2d7, inset -1px -1px #3e4746, 0 7px 18px rgba(0,0,0,0.52);
  color: #151a1b;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  z-index: 9;
}
html[data-ui="bryce"] .sliderrow,
html[data-ui="bryce"] .hint { color: #303a3b; }
html[data-ui="bryce"] #dock {
  bottom: 7px;
  width: min(660px, calc(100vw - 330px));
  min-width: 390px;
  gap: 2px;
  padding: 18px 12px 6px;
  border: 1px solid #252b2c;
  border-radius: 5px 18px 5px 12px;
  background:
    linear-gradient(145deg, rgba(255,255,255,0.64), transparent 29%),
    linear-gradient(140deg, #b6b7ae, #69716f);
  box-shadow: inset 1px 1px #e0dfd4, inset -1px -1px #414948, 0 5px 14px rgba(0,0,0,0.48);
  color: #151a1b;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  z-index: 9;
}
html[data-ui="bryce"] #dock::before {
  content: "TIME  •  SKY CYCLE";
  position: absolute;
  top: 5px;
  left: 12px;
  font-size: 7px;
  font-weight: 900;
  letter-spacing: 0.12em;
  opacity: 0.72;
}
html[data-ui="bryce"] .dock-label { color: #263132; }
html[data-ui="bryce"] .round {
  border: 1px solid #394142;
  background: radial-gradient(circle at 36% 30%, #e8e9df, #7b8380 57%, #444d4c);
  box-shadow: inset -3px -4px rgba(29,36,37,0.28), 0 1px 3px rgba(0,0,0,0.55);
  color: #172021;
}
html[data-ui="bryce"] .round.go { background: radial-gradient(circle at 35% 30%, #ffe2a7, #d7903f 58%, #7b4828); }
html[data-ui="bryce"] input[type="range"]::-webkit-slider-runnable-track {
  height: 7px;
  border: 1px solid #343c3d;
  border-radius: 2px;
  background: linear-gradient(#283234, #657271);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.75), 0 1px rgba(255,255,255,0.46);
}
html[data-ui="bryce"] input[type="range"]::-webkit-slider-thumb {
  width: 22px;
  height: 22px;
  margin-top: -8px;
  border: 1px solid #284c54;
  background: radial-gradient(circle at 35% 28%, #e6ffff, #5baab5 48%, #285762 75%);
  box-shadow: inset -3px -4px rgba(20,58,64,0.36), 0 2px 4px rgba(0,0,0,0.66);
}
html[data-ui="bryce"] #describeBar .descrow,
html[data-ui="bryce"] .toast,
html[data-ui="bryce"] #walkHint {
  border: 1px solid #2d3536;
  border-radius: 6px 18px 6px 12px;
  background: linear-gradient(145deg, #c1c2b8, #717976);
  color: #171d1e;
  box-shadow: inset 1px 1px rgba(255,255,255,0.72), 0 5px 14px rgba(0,0,0,0.52);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
html[data-ui="bryce"] #descInput { color: #141a1b; }
html[data-ui="bryce"] #descInput::placeholder { color: #465052; }
html[data-ui="bryce"] #sheet { background: rgba(20, 25, 25, 0.74); }
html[data-ui="bryce"] .panel {
  border-color: #242a2b;
  border-radius: 9px 24px 0 0;
  background:
    linear-gradient(145deg, rgba(255,255,255,0.68), transparent 24%),
    linear-gradient(150deg, #b7b8af, #707875);
  color: #151a1b;
  box-shadow: inset 1px 1px #e7e6dc, 0 -7px 24px rgba(0,0,0,0.5);
}
html[data-ui="bryce"] .panel h3 { color: #334042; }
html[data-ui="bryce"] .card,
html[data-ui="bryce"] .export-btn,
html[data-ui="bryce"] .import-card { background: rgba(28,36,37,0.12); border-color: rgba(34,43,44,0.48); }
html[data-ui="bryce"] .sel,
html[data-ui="bryce"] .text {
  background: rgba(235,236,225,0.45);
  border-color: #4b5555;
  color: #151a1b;
}
html[data-ui="bryce"] .big-btn { color: #102125; }

@media (max-width: 1060px) {
  html[data-ui="bryce"] .bryce-room { width: 64px; }
  html[data-ui="bryce"] .bryce-roombar { left: 74px; }
  html[data-ui="bryce"] .chip-label { display: none; }
}

@media (max-width: 700px) {
  html[data-ui="bryce"] .bryce-menubar { height: calc(25px + env(safe-area-inset-top, 0px)); padding-top: env(safe-area-inset-top, 0px); }
  html[data-ui="bryce"] .bryce-menuitem { display: none; }
  html[data-ui="bryce"] .bryce-wordmark { font-size: 11px; letter-spacing: 0.13em; }
  html[data-ui="bryce"] .bryce-wordmark i { font-size: 7px; }
  html[data-ui="bryce"] .bryce-roombar {
    top: calc(30px + env(safe-area-inset-top, 0px));
    left: 7px;
    right: 7px;
    justify-content: stretch;
    gap: 4px;
    padding: 4px;
  }
  html[data-ui="bryce"] .bryce-room { flex: 1 1 0; width: auto; height: 47px; }
  html[data-ui="bryce"] .bryce-orb { width: 27px; height: 27px; top: 5px; left: 7px; }
  html[data-ui="bryce"] .bryce-viewpalette { display: none; }
  html[data-ui="bryce"] #topbar {
    top: calc(82px + env(safe-area-inset-top, 0px));
    padding: 5px calc(7px + env(safe-area-inset-right, 0px)) 5px calc(7px + env(safe-area-inset-left, 0px));
  }
  html[data-ui="bryce"] .top-actions { width: 100%; justify-content: flex-end; }
  html[data-ui="bryce"] #topbar .chip { min-height: 36px; padding: 7px 10px; }
  html[data-ui="bryce"] #rail {
    --rail-top: calc(129px + env(safe-area-inset-top, 0px));
    --rail-bottom: calc(124px + var(--safe-b));
  }
  html[data-ui="bryce"] #toolopts {
    left: 7px;
    right: 7px;
    top: auto;
    bottom: calc(7px + var(--safe-b));
    border-radius: 5px 18px 5px 12px;
  }
  html[data-ui="bryce"] #dock {
    width: calc(100vw - 16px);
    min-width: 0;
    bottom: calc(6px + var(--safe-b));
  }
  html[data-ui="bryce"] .bryce-status { display: none; }
  html[data-ui="bryce"] #toasts { top: calc(130px + env(safe-area-inset-top, 0px)); bottom: auto; }
  html[data-ui="bryce"] body.mode-open #toasts,
  html[data-ui="bryce"] body.walk-open #toasts { top: calc(130px + env(safe-area-inset-top, 0px)); }
}

@media (max-width: 380px) {
  html[data-ui="bryce"] .bryce-room b { font-size: 7px; }
  html[data-ui="bryce"] .bryce-wordmark i { display: none; }
  #bryceExit { padding-inline: 6px; }
}
