/* ============================================================================
   CITY GENERATOR  ·  stylesheet (the City Atlas sheet: head, foot, chips,
   drawers and the phone sheets, plus the playback bar and the export list)
   ----------------------------------------------------------------------------
   The map fills the window. The text has the look of the shell screensaver
   plate: STIX Two Text for the title and the values, Inter in spaced
   capitals for the small labels, a hairline rule, and a boxed mark with
   brackets in the section colour. main.js sets --c on <html> from
   lib/nav-data.js.

   grep -n targets
     'HEAD'      category, title, rule, seed line
     'FOOT'      parameters, notes, playback bar, controls
     'CHIPS'     Map, 3D and Field toggles
     'PANEL'     the settings drawer: groups, sliders, switches
     'SHEETS'    export list and about sheet
     'DOCK'      the phone dock and playback bar (hidden on a desktop)
     'PHONE'     the phone block (layout.js PHONE_Q): dock, sheets, accordion
     'LANDSCAPE' the short landscape block (layout.js LAND_Q): the drawer
     'COARSE'    touch screens: 44px targets, 11px text
     'SAVER'     what saver mode hides
   ========================================================================== */
:root {
  --c: #50c0ff;
  --fs: min(100vw, 80vh);
  --serif: var(--sci-serif, 'STIX Two Text', Georgia, serif);
  --sans: var(--sci-sans, Inter, system-ui, sans-serif);
  --cream: #f4f1ea;
  --cream2: #e2ddd1;
  --cream3: #cfc9bc;
  --cap: #a4acb8;
  --line: rgba(244, 240, 230, 0.85);
  --box: #0c0f15;
  --edge: rgba(255, 255, 255, 0.08);
  --dim: #8591a3;
  --dim2: #6c7788;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #000;
  color: var(--cream);
  font-family: var(--sans);
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
body { position: fixed; inset: 0; }
[hidden] { display: none !important; }
button { font-family: inherit; touch-action: manipulation; }

#stage { position: fixed; inset: 0; height: 100dvh; background: #000; touch-action: none; overflow: hidden; }
body.idle #stage { cursor: none; }
#map2d, #map3d { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#map2d { cursor: grab; }
#map2d.drag { cursor: grabbing; }
#veil {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to bottom, rgba(0,0,0,.6) 0, rgba(0,0,0,.22) 14%, transparent 26%, transparent 60%, rgba(0,0,0,.5) 76%, rgba(0,0,0,.86) 100%);
}

/* HEAD. The plate's top block, smaller: the map must stay in view. */
#head {
  position: absolute; left: 50%; top: 0;
  transform: translateX(-50%);
  width: min(100%, 980px);
  padding: max(clamp(18px, calc(var(--fs) * .05), 56px), calc(env(safe-area-inset-top, 0px) + 12px)) 16px 0;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  pointer-events: none;
  text-shadow: 0 1px 14px rgba(0, 0, 0, .85);
}
#cat {
  font: 500 clamp(9px, calc(var(--fs) * .015), 12px)/1 var(--sans);
  letter-spacing: .34em; padding-left: .34em; text-transform: uppercase;
  color: var(--c); margin: 0 0 .9em;
}
#ttl {
  margin: 0; max-width: 24ch;
  font: 400 clamp(26px, calc(var(--fs) * .066), 64px)/1.04 var(--serif);
  color: #f8f5ee; text-wrap: balance;
}
#head .rule {
  display: block; width: min(70%, 480px); height: 1px;
  margin: clamp(10px, calc(var(--fs) * .022), 20px) 0 clamp(8px, calc(var(--fs) * .018), 16px);
  background: linear-gradient(90deg, transparent, rgba(244,240,230,.9) 16%, rgba(244,240,230,.9) 84%, transparent);
  transform: scaleX(0); transition: transform 1.4s cubic-bezier(.22,.7,.12,1) .2s;
}
body.shown #head .rule { transform: scaleX(1); }
#sub {
  max-width: 34em;
  font: italic 400 clamp(13px, calc(var(--fs) * .024), 21px)/1.3 var(--serif);
  color: var(--cream2); text-wrap: balance;
}

/* FOOT. Parameters, notes, the week bar and the controls, centred. */
#foot {
  position: absolute; left: 50%; bottom: 0;
  transform: translateX(-50%);
  width: min(100%, 980px);
  padding: 0 16px max(clamp(14px, calc(var(--fs) * .03), 34px), calc(env(safe-area-inset-bottom, 0px) + 10px));
  display: flex; flex-direction: column; align-items: center; text-align: center;
  pointer-events: none;
  text-shadow: 0 1px 14px rgba(0, 0, 0, .85);
}
#params {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end;
  gap: .6em 1.9em; font: 400 clamp(13px, calc(var(--fs) * .022), 19px)/1.25 var(--serif);
}
/* The ramp and the scale bar sit in the gap between value and label, out of
   flow, so every value stays on one baseline. */
.p { position: relative; display: inline-flex; flex-direction: column; align-items: center; }
.p .v { font-style: italic; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--cream); }
.p .v .sym { font-style: italic; }
.p .v .m1 { color: #62c4ff; }
.p small {
  margin-top: .8em;
  font: 400 .56em/1.2 var(--sans); letter-spacing: .16em; text-transform: uppercase;
  color: var(--cap); text-shadow: none; white-space: nowrap;
}
.p .ramp { position: absolute; left: 0; right: 0; bottom: 1.02em; height: 2px; border-radius: 1px; }
.p .bar { position: absolute; left: 50%; bottom: .98em; height: 4px; transform: translateX(-50%); border: solid rgba(244,240,230,.7); border-width: 0 1px 1px; }
#notes {
  max-width: 44em; margin-top: .75em;
  font: italic 400 clamp(12px, calc(var(--fs) * .019), 16px)/1.4 var(--serif);
  color: var(--cream3);
}
#notes .src {
  display: block; margin-top: .55em;
  font: 400 .62em/1.3 var(--sans); font-style: normal; letter-spacing: .14em; text-transform: uppercase;
  color: var(--cap); text-shadow: none;
}

/* The playback: a hairline as wide as the head rule. Phase ticks, a filled
   part and a small knob. Drag it to scrub the build. */
#scrub {
  position: relative; width: min(70%, 480px); height: 1px;
  margin: clamp(12px, calc(var(--fs) * .024), 20px) 0 clamp(10px, calc(var(--fs) * .02), 16px);
  background: linear-gradient(90deg, transparent, rgba(244,240,230,.32) 10%, rgba(244,240,230,.32) 90%, transparent);
  pointer-events: auto; cursor: pointer; touch-action: none;
}
#scrub::after { content: ''; position: absolute; inset: -14px 0; }
#scrub .fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 100%;
  transform-origin: 0 50%; transform: scaleX(0);
  background: linear-gradient(90deg, transparent, var(--line) 10%);
}
#scrub .knob {
  position: absolute; top: 50%; left: 0; width: 7px; height: 7px;
  transform: translate(-50%, -50%); border-radius: 50%;
  background: var(--c); box-shadow: 0 0 10px var(--c);
}
#scrub .tick { position: absolute; top: -3px; width: 1px; height: 7px; background: rgba(244,240,230,.4); }

#controls {
  display: flex; align-items: center; gap: 4px;
  pointer-events: auto; transition: opacity 600ms ease;
}
body.idle #controls { opacity: .18; }
body.idle #controls:hover, body.idle #controls:focus-within { opacity: 1; }
#controls button {
  appearance: none; margin: 0; padding: 0;
  min-width: 38px; height: 38px; border: 0; border-radius: 4px;
  background: transparent; color: var(--cream);
  font: 400 24px/1 var(--serif); cursor: pointer;
  display: grid; place-items: center;
}
#controls button:hover { color: var(--c); }
#controls button:focus-visible { outline: 1px solid var(--line); outline-offset: 2px; }
#controls #prev, #controls #next { font-size: 28px; padding-bottom: 3px; }
#controls #play svg { width: 13px; height: 13px; fill: currentColor; }
#controls #info { font: italic 400 19px/1 var(--serif); }
#controls #info[aria-pressed="true"] { color: var(--c); }
#controls .sep { width: 1px; height: 20px; background: rgba(244,240,230,.25); margin: 0 6px; }
/* The location box: the site mark of the plate, as a button. */
#controls #where {
  display: inline-flex; align-items: baseline; gap: 0; height: auto;
  margin: 0 6px; padding: .5em .5em .5em .2em;
  font: 500 clamp(13px, calc(var(--fs) * .02), 17px)/1 var(--serif);
  letter-spacing: .1em; white-space: nowrap;
  border: 1px solid var(--line); border-radius: 0;
  background: rgba(5, 7, 11, .58);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
#controls #where:hover, #controls #where[aria-expanded="true"] { color: var(--cream); border-color: var(--c); }
#where .br { color: var(--c); letter-spacing: 0; padding: 0 .4em; }
#seedName { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
#seedSize { margin-left: .8em; font: 400 .66em/1 var(--sans); letter-spacing: .12em; color: var(--cap); font-variant-numeric: tabular-nums; }

/* fade, loading, fallback */
#fade { position: absolute; inset: 0; background: #000; opacity: 1; transition: opacity 320ms ease; pointer-events: none; }
#fade.clear { opacity: 0; }
#loading {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 10px;
  font: 500 11px/1 var(--sans); letter-spacing: .24em; text-transform: uppercase; color: var(--cap);
}
#loading span { width: 5px; height: 5px; border-radius: 50%; background: var(--c); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: .2; } 50% { opacity: 1; } }
#fallback { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(88vw, 440px); text-align: center; }
#fallback p { margin: 0; font: italic 400 clamp(14px, 2vw, 18px)/1.5 var(--serif); color: var(--cream3); }

/* SHEETS. The export list and the about sheet, in the look of the saver menu. */
#scrim { position: fixed; inset: 0; z-index: 10; background: rgba(0, 0, 0, .4); }
.sheet {
  position: fixed; top: 12px; right: 12px; bottom: 12px;
  width: min(400px, calc(100vw - 24px)); z-index: 11;
  display: flex; flex-direction: column;
  background: var(--box); border: 1px solid var(--edge); border-radius: 14px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .55);
  color: #c9d2df; font: 400 14px/1.45 var(--sans);
  animation: sheetSide 240ms cubic-bezier(.2, .8, .2, 1);
}
@keyframes sheetSide { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.close {
  position: absolute; top: 12px; right: 12px; width: 34px; height: 34px;
  border: 0; border-radius: 8px; background: transparent; color: var(--dim);
  font: 300 22px/1 var(--sans); cursor: pointer;
}
.close:hover { background: rgba(255, 255, 255, .06); color: #f1f4f8; }
.grip { display: none; }

#caption { display: block; overflow: auto; padding: 20px 22px 18px; -webkit-user-select: text; user-select: text; }
#caption h2 { margin: 0 40px 12px 0; font: 400 24px/1.1 var(--serif); color: #f8f5ee; }
#caption h2 small { display: block; margin-top: 6px; font: italic 400 15px/1.3 var(--serif); color: var(--cream2); }
#caption p { margin: 0 0 10px; font-size: 13.5px; line-height: 1.6; color: #c9d2df; }
#caption p.data { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--edge); font-size: 12px; color: var(--dim); }
#caption .credits { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--edge); }
#caption .credits h3 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: #e6ebf2; }
#caption .credits ul { margin: 0; padding: 0; list-style: none; }
#caption .credits li { margin: 0 0 8px; font-size: 12px; line-height: 1.55; color: var(--dim); }
#caption .credits a { color: var(--c); text-underline-offset: 2px; }
#caption .credits a:hover { color: #cfeaff; }

#save header, #panel header { position: relative; display: flex; align-items: baseline; gap: 10px; padding: 18px 20px 12px; border-bottom: 1px solid var(--edge); }
#save header h2, #panel header h2 { margin: 0; font-size: 1.2rem; font-weight: 600; color: #f1f4f8; }
#saveBody { flex: 1; overflow: auto; overscroll-behavior: contain; touch-action: pan-y; padding: 8px 16px 18px; }
.ex { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px; margin: 12px 0 0; padding: 12px; border: 1px solid var(--edge); border-radius: 10px; background: rgba(255,255,255,.02); }
.ex b { font-size: .9rem; font-weight: 600; color: #e6ebf2; }
.ex p { grid-column: 1; margin: 0; font-size: 12px; line-height: 1.5; color: var(--dim); }
.ex button, .lg .btn { grid-row: 1 / span 2; grid-column: 2; appearance: none; border: 1px solid color-mix(in srgb, var(--c) 55%, transparent); border-radius: 8px; background: color-mix(in srgb, var(--c) 12%, transparent); color: #f1f4f8; padding: 9px 14px; font: 500 12px/1 var(--sans); letter-spacing: .06em; cursor: pointer; }
.ex button:hover, .lg .btn:hover { background: color-mix(in srgb, var(--c) 24%, transparent); }
.ex button:disabled { opacity: .4; cursor: default; }
#saveNote { margin: 14px 2px 0; font-size: 11.5px; line-height: 1.5; color: var(--dim2); }

/* CHIPS. The overlay toggles: small boxed labels with a dot in the overlay colour. */
#chips { display: flex; gap: 8px; margin: 0 0 clamp(6px, calc(var(--fs) * .012), 12px); pointer-events: auto; transition: opacity 600ms ease; }
body.idle #chips { opacity: .18; }
body.idle #chips:hover, body.idle #chips:focus-within { opacity: 1; }
.chip {
  appearance: none; display: inline-flex; align-items: center; gap: .55em;
  height: 30px; padding: 0 .9em; border: 1px solid rgba(244,240,230,.28); border-radius: 15px;
  background: rgba(5, 7, 11, .5); color: var(--cream3);
  font: 500 11px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; cursor: pointer;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  transition: border-color 160ms, color 160ms, background 160ms;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; border: 1px solid currentColor; box-sizing: border-box; }
.chip:hover { color: var(--cream); border-color: rgba(244,240,230,.5); }
.chip[aria-pressed="true"] { color: var(--cream); border-color: var(--k, var(--c)); background: color-mix(in srgb, var(--k, var(--c)) 14%, rgba(5,7,11,.55)); }
.chip[aria-pressed="true"] .dot { background: var(--k, var(--c)); border-color: var(--k, var(--c)); box-shadow: 0 0 8px var(--k, var(--c)); }
.chip:disabled { opacity: .35; cursor: default; }
#chip2d { --k: #f0d39a; }
#chip3d { --k: #7fb4e6; }
#chipField { --k: #96b9dc; }
#chipTerrain { --k: #a8c487; }
#controls svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
#controls #end svg, #controls #play svg { width: 13px; height: 13px; fill: currentColor; stroke: none; }
#controls #dice svg circle { fill: currentColor; stroke: none; }
#controls #speed { font: 500 13px/1 var(--sans); letter-spacing: .04em; min-width: 40px; font-variant-numeric: tabular-nums; }
#controls button[aria-expanded="true"] { color: var(--c); }
#phase { display: block; min-height: 1.4em; }

/* PANEL. The generator settings: a drawer on the left. */
.sheet.left { right: auto; left: 12px; width: min(340px, calc(100vw - 24px)); animation-name: sheetLeft; }
@keyframes sheetLeft { from { transform: translateX(-24px); opacity: 0; } to { transform: none; opacity: 1; } }
#panelBody { flex: 1; overflow: auto; overscroll-behavior: contain; touch-action: pan-y; padding: 4px 16px 18px; scrollbar-width: thin; scrollbar-color: #26303c transparent; }
.lg { margin: 14px 0 0; padding: 12px 12px 10px; border: 1px solid var(--edge); border-radius: 10px; background: rgba(255,255,255,.02); }
.lg.on { border-color: color-mix(in srgb, var(--k, var(--c)) 45%, transparent); }
.lg h3 { display: flex; align-items: center; gap: 9px; margin: 0 0 4px; font-size: .9rem; font-weight: 600; color: #e6ebf2; }
.lg h3 .sw { margin-left: auto; }
.lg .why { margin: 0 0 8px; font-size: 12px; line-height: 1.5; color: var(--dim); }
.lg .row { display: grid; grid-template-columns: 92px 1fr 64px; align-items: center; gap: 8px; margin: 8px 0; font-size: 12px; color: #c9d2df; }
.lg .row output { text-align: right; font-variant-numeric: tabular-nums; color: var(--cream2); }
.lg .row.two { grid-template-columns: 92px 1fr; }
.lg .seg { display: inline-flex; border: 1px solid var(--edge); border-radius: 7px; overflow: hidden; }
.lg .seg button { appearance: none; border: 0; background: transparent; color: var(--dim); padding: 6px 9px; font: 500 11.5px/1 var(--sans); cursor: pointer; }
.lg .seg button[aria-pressed="true"] { background: color-mix(in srgb, var(--k, var(--c)) 22%, transparent); color: #f1f4f8; }
.lg .src { margin: 8px 0 0; font-size: 11px; line-height: 1.5; color: var(--dim2); }
.lg .src a { color: var(--dim); }
.lg .legend { position: relative; height: 8px; margin: 10px 0 2px; border-radius: 4px; }
.lg .legend + .ticks { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--dim); font-variant-numeric: tabular-nums; }
.lg .status { font-size: 11.5px; color: var(--dim); min-height: 1.4em; }
.lg .status.err { color: #e8a37a; }
.sw { appearance: none; position: relative; width: 34px; height: 20px; border-radius: 10px; border: 1px solid var(--edge); background: #1a2029; cursor: pointer; flex: none; padding: 0; }
.sw::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #8591a3; transition: transform 160ms, background 160ms; }
.sw[aria-checked="true"] { background: color-mix(in srgb, var(--k, var(--c)) 45%, #1a2029); border-color: var(--k, var(--c)); }
.sw[aria-checked="true"]::after { transform: translateX(14px); background: #f4f1ea; }
.lg[data-k="field"] { --k: #96b9dc; }
.lg[data-k="water"] { --k: #3fc4e8; }
.lg[data-k="roads"] { --k: #f0d39a; }
.lg[data-k="build"] { --k: #e0b46a; }
.lg[data-k="view"] { --k: var(--c); }
.lg[data-k="terrain"] { --k: #a8c487; }
.lg h3 .roll { appearance: none; margin-left: auto; width: 26px; height: 22px; padding: 0; border: 1px solid var(--edge); border-radius: 6px; background: transparent; color: var(--dim); cursor: pointer; display: grid; place-items: center; }
.lg h3 .roll svg { width: 14px; height: 14px; stroke: currentColor; fill: currentColor; stroke-width: 1.2; }
.lg h3 .roll svg rect { fill: none; }
.lg h3 .roll:hover { color: #f1f4f8; border-color: var(--k, var(--c)); }
.lg h3 .roll + .keep { margin-left: 4px; font-size: 11px; font-weight: 500; color: var(--dim); }
.lg h3 .roll ~ .sw { margin-left: 0; }
.lg .row select { width: 100%; padding: 6px 8px; border: 1px solid var(--edge); border-radius: 7px; background: #0f131a; color: var(--cream); font: 400 13px/1.2 var(--sans); }
.lg .seg { flex-wrap: wrap; }
.lg .row input[type="number"] { width: 100%; padding: 6px 8px; border: 1px solid var(--edge); border-radius: 7px; background: #0f131a; color: var(--cream); font: 400 13px/1 var(--sans); font-variant-numeric: tabular-nums; }
.lg .btn { display: block; width: 100%; margin-top: 12px; padding: 11px 14px; font-size: 13px; }
.lg .row.btns { grid-template-columns: 1fr 1fr; }
.lg .row.btns .btn { margin: 0; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; margin: 0; background: transparent; touch-action: manipulation; }
input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: rgba(244,240,230,.25); border-radius: 1px; }
input[type="range"]::-moz-range-track { height: 2px; background: rgba(244,240,230,.25); border-radius: 1px; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -6px; border-radius: 50%; background: var(--k, var(--c)); border: 0; box-shadow: 0 0 8px color-mix(in srgb, var(--k, var(--c)) 60%, transparent); }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--k, var(--c)); border: 0; }
input[type="range"]:disabled { opacity: .4; }

/* the about sheet: a small table of numbers */
#caption .facts { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 12px 0; font-size: 12.5px; color: #c9d2df; }
#caption .facts span:nth-child(2n) { text-align: right; color: var(--cream2); font-variant-numeric: tabular-nums; }
#caption h3.sub { margin: 16px 0 6px; font-size: 13px; font-weight: 600; color: #e6ebf2; }
#caption a { color: var(--c); text-underline-offset: 2px; }

/* DOCK, PBAR. Phone only (see PHONE); on a desktop #pbar is only a wrapper. */
#dock, #pSpeed, #pEnd, .hbtn { display: none; }
#pbar { display: contents; }
.lg .acc { all: unset; flex: 0 1 auto; min-width: 0; font: inherit; color: inherit; }
.lg .acc .chev { display: none; }
.lg .row.seed { grid-template-columns: 92px auto 1fr auto; }
.lg .row.seed .step { appearance: none; width: 30px; height: 28px; padding: 0; border: 1px solid var(--edge); border-radius: 7px; background: transparent; color: var(--cream2); font: 400 18px/1 var(--serif); cursor: pointer; }
#loading .bar { position: absolute; left: 0; right: 0; top: calc(100% + 10px); height: 2px; border-radius: 1px; background: rgba(244, 240, 230, .18); overflow: hidden; }
#loading .bar b { display: block; height: 100%; width: 0; background: var(--c); transition: width 200ms linear; }
#loading #loadText { font: inherit; white-space: nowrap; }

/* PHONE. layout.js PHONE_Q: a window 768px wide or less, or a short touch
   screen. A dock at the base, the playback bar above it, the sheets above
   the dock. main.js frames the map in the clear area. */
@media (max-width: 768px), (max-height: 500px) and (pointer: coarse) {
  :root { --dock-h: calc(64px + env(safe-area-inset-bottom, 0px)); }
  #head { padding-left: calc(12px + env(safe-area-inset-left, 0px)); padding-right: calc(12px + env(safe-area-inset-right, 0px)); }
  #ttl { font-size: clamp(24px, 7.4vw, 34px); }
  #sub { font-size: 13px; }
  #veil { background: linear-gradient(to bottom, rgba(0,0,0,.6) 0, rgba(0,0,0,.2) 16%, transparent 28%, transparent 62%, rgba(0,0,0,.55) 82%, rgba(0,0,0,.8) 100%); }
  #foot { bottom: var(--dock-h); padding: 0 calc(12px + env(safe-area-inset-right, 0px)) 4px calc(12px + env(safe-area-inset-left, 0px)); }
  #params { gap: .5em 1.3em; font-size: 14px; }
  #notes { font-size: 12px; margin-top: .5em; }
  #notes .src, #controls, #chips { display: none; }
  body.sheet-up #head { display: none; }

  #dock {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 9; gap: 6px; align-items: center;
    padding: 8px calc(10px + env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) calc(10px + env(safe-area-inset-left, 0px));
    background: rgba(8, 10, 14, .94); border-top: 1px solid var(--edge);
  }
  #dock > button {
    flex: 0 0 48px; height: 48px; padding: 0; display: grid; place-items: center;
    border: 1px solid rgba(244, 240, 230, .18); border-radius: 12px; background: #10141b; color: var(--cream); cursor: pointer;
  }
  #dock svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
  #dock .pip { fill: currentColor; stroke: none; }
  #dockPlay svg { width: 16px; height: 16px; fill: currentColor; stroke: none; }
  #dock > button[aria-pressed="true"], #dock > button[aria-expanded="true"] { border-color: var(--k, var(--c)); color: var(--k, var(--c)); }
  #dockTerrain { --k: #a8c487; }
  .dseg { flex: 1 1 auto; min-width: 88px; display: flex; height: 48px; border: 1px solid rgba(244, 240, 230, .18); border-radius: 12px; overflow: hidden; }
  .dseg button { flex: 1; min-width: 44px; border: 0; border-right: 1px solid var(--edge); background: #10141b; color: var(--dim); font: 500 12px/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; cursor: pointer; }
  .dseg button:last-child { border-right: 0; }
  .dseg button[aria-pressed="true"] { background: color-mix(in srgb, var(--c) 18%, #10141b); color: var(--cream); }

  /* the playback bar: speed, a thumb sized scrubber, skip to the end */
  #pbar { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 560px; margin-top: 6px; pointer-events: auto; }
  #pSpeed, #pEnd {
    display: grid; place-items: center; flex: 0 0 44px; height: 44px; padding: 0;
    border: 0; border-radius: 10px; background: rgba(5, 7, 11, .5); color: var(--cream);
    font: 500 13px/1 var(--sans); font-variant-numeric: tabular-nums; cursor: pointer;
  }
  #pEnd svg { width: 14px; height: 14px; fill: currentColor; }
  #scrub { flex: 1; width: auto; height: 4px; margin: 0; border-radius: 2px; background: rgba(244, 240, 230, .22); }
  #scrub::after { inset: -20px 0; }
  #scrub .fill { background: var(--line); border-radius: 2px; }
  #scrub .knob { width: 20px; height: 20px; border: 2px solid #0c0f15; }
  #scrub .tick { top: -4px; height: 12px; }

  /* the sheets sit above the dock */
  .sheet {
    left: 0; right: 0; bottom: var(--dock-h); top: auto;
    width: auto; max-width: 640px; margin: 0 auto;
    max-height: calc(100dvh - var(--dock-h) - 40px); border-radius: 16px 16px 0 0; border-bottom: 0;
    animation: sheetUp 280ms cubic-bezier(.2, .8, .2, 1);
    transition: transform 120ms ease, height 250ms cubic-bezier(.4, 0, .2, 1);
  }
  .sheet.left { left: 0; right: 0; width: auto; animation-name: sheetUp; }
  #panel { height: min(50dvh, 560px); }
  #panel.full { height: calc(100dvh - var(--dock-h) - 40px); }
  #save { max-height: min(72dvh, calc(100dvh - var(--dock-h) - 40px)); }
  #caption { padding: 0 calc(20px + env(safe-area-inset-right, 0px)) 20px calc(20px + env(safe-area-inset-left, 0px)); overscroll-behavior: contain; touch-action: pan-y; }
  #panel header, #save header { padding: 2px calc(18px + env(safe-area-inset-right, 0px)) 10px calc(18px + env(safe-area-inset-left, 0px)); align-items: center; }
  #panel header .close, #save header .close { position: static; margin-left: auto; width: 44px; height: 44px; }
  #panel header h2 { margin-right: auto; }
  .hbtn {
    display: inline-grid; place-items: center; min-width: 64px; height: 44px; padding: 0 12px;
    border: 1px solid var(--edge); border-radius: 10px; background: transparent; color: #c9d2df;
    font: 500 12px/1 var(--sans); letter-spacing: .08em; cursor: pointer;
  }
  #panelBody, #saveBody { padding: 4px calc(14px + env(safe-area-inset-right, 0px)) 20px calc(14px + env(safe-area-inset-left, 0px)); }
  .grip { display: block; height: 28px; flex: none; position: relative; touch-action: none; cursor: grab; }
  #caption .grip { margin: 0 -20px 4px; }
  .grip::after { content: ''; position: absolute; left: 50%; top: 10px; width: 46px; height: 5px; margin-left: -23px; border-radius: 3px; background: rgba(255, 255, 255, .3); }
  #caption .close { top: 26px; width: 44px; height: 44px; }

  /* the accordion: a section shows its body when it is open */
  .lg { padding: 0 12px; margin-top: 10px; }
  .lg > .lgb { display: none; padding-bottom: 10px; }
  .lg.open > .lgb { display: block; }
  .lg h3 { min-height: 52px; margin: 0; gap: 6px; }
  .lg .acc { flex: 1 1 auto; display: flex; align-items: center; gap: 10px; min-height: 52px; cursor: pointer; font-size: 15px; }
  .lg .acc .chev { display: block; width: 8px; height: 8px; flex: none; border: solid var(--dim); border-width: 0 1.5px 1.5px 0; transform: rotate(-45deg); transition: transform 160ms; }
  .lg.open .acc .chev { transform: rotate(45deg); }
  .lg h3 .roll { margin-left: 0; }
  .lg .why { font-size: 12px; }
  .lg .row { grid-template-columns: 1fr auto; gap: 0 10px; min-height: 44px; margin: 4px 0; font-size: 13px; }
  .lg .row > input[type="range"] { grid-column: 1 / -1; grid-row: 2; }
  .lg .row output { grid-column: 2; grid-row: 1; }
  .lg .row.two { grid-template-columns: 96px 1fr; }
  .lg .row.two > .sw { justify-self: end; }
  .lg .row.seed { grid-template-columns: 64px 44px 1fr 44px; }
  .lg .row.seed .step { width: 44px; height: 44px; }
  .lg .seg button { min-height: 44px; min-width: 44px; padding: 6px 11px; font-size: 12px; }
  .lg .row select, .lg .row input[type="number"] { min-height: 44px; font-size: 16px; }
  .lg .btn { min-height: 44px; }
  .lg .src { font-size: 11px; }
  .ex { gap: 6px 12px; }
  .ex button { min-height: 44px; min-width: 72px; font-size: 13px; }
  .ex p, #saveNote { font-size: 12px; }
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* LANDSCAPE. layout.js LAND_Q: a short landscape touch screen. The dock
   and the playback bar are at the lower left, the settings a drawer on the
   right edge, the head a small block at the upper left. */
@media (max-height: 500px) and (orientation: landscape) and (pointer: coarse), (max-height: 500px) and (orientation: landscape) and (max-width: 768px) {
  #head { left: 0; transform: none; width: min(440px, 52vw); align-items: flex-start; text-align: left; padding: max(8px, env(safe-area-inset-top, 0px)) 12px 0 calc(14px + env(safe-area-inset-left, 0px)); }
  #cat { margin-bottom: .45em; }
  #ttl { font-size: 20px; }
  #head .rule, #sub, #params { display: none; }
  #dock { right: auto; width: min(440px, 52vw); border-right: 1px solid var(--edge); border-radius: 0 16px 0 0; }
  #foot { left: 0; transform: none; width: min(440px, 52vw); align-items: stretch; text-align: left; padding-left: calc(10px + env(safe-area-inset-left, 0px)); }
  #notes { margin-top: 0; }
  .sheet, .sheet.left, #panel, #panel.full, #save {
    top: 0; bottom: 0; left: auto; right: 0; width: min(46vw, 400px); height: auto; max-height: none; max-width: none; margin: 0;
    border-radius: 0; border: 0; border-left: 1px solid var(--edge);
    padding-right: env(safe-area-inset-right, 0px);
    animation-name: sheetSide;
  }
  #caption { padding-top: 12px; }
  #panel header, #save header { padding-top: 8px; }
  .grip, #caption .grip { display: none; }
  #caption .close { top: 8px; }
}

/* COARSE. Any touch screen, phone or tablet: every target is 44px or more
   and all text is 11px or more. */
@media (pointer: coarse) {
  #cat { font-size: 11px; }
  .p small { font-size: 11px; }
  #seedSize { font-size: 11px; }
  #notes .src { font-size: 11px; }
  #controls button { min-width: 44px; height: 44px; }
  .chip { height: 44px; font-size: 11px; }
  .close { width: 44px; height: 44px; }
  .lg h3 .roll { width: 44px; height: 44px; }
  .lg h3 .roll + .keep { font-size: 11px; }
  .lg .row select, .lg .seg button { min-height: 44px; }
  .lg .legend + .ticks { font-size: 11px; }
  .lg .row.seed .step { width: 44px; height: 44px; }
  .ex button { min-height: 44px; }
  .sw { width: 52px; height: 30px; border-radius: 15px; }
  .sw::before { content: ''; position: absolute; inset: -8px -4px; }
  .sw::after { top: 3px; left: 3px; width: 22px; height: 22px; }
  .sw[aria-checked="true"]::after { transform: translateX(22px); }
  input[type="range"] { height: 44px; }
  input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; }
  input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; }
  input[type="range"]::-webkit-slider-thumb { width: 26px; height: 26px; margin-top: -10px; border: 3px solid #0c0f15; }
  input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; border: 3px solid #0c0f15; }
}

/* SAVER. The shell plate names the city, so the page shows the view only. */
body.saver #head, body.saver #foot, body.saver #veil,
body.saver .sheet, body.saver #scrim, body.saver #loading, body.saver #dock { display: none !important; }
body.saver, body.saver #stage { cursor: none; }

@media (prefers-reduced-motion: reduce) {
  #fade, #controls, #head .rule { transition: none; }
  .sheet { animation: none; }
  #loading span { animation: none; opacity: .7; }
}
