/* ============================================================================
   COLLAPSE CITY  ·  stylesheet
   ----------------------------------------------------------------------------
   The WebGPU canvas fills the window. Desktop: the panel is a drawer on the
   right edge. Type comes from lib/sci.css (Inter for text, the system mono
   for numbers only).

   PHONE (max-width 768px, or a short landscape touch screen): the pattern of
   pages/wave-membrane. A dock at the base holds the mode and New city. In
   portrait the panel is a bottom sheet above the dock; in landscape it is a
   drawer on the right edge. Every control is 44px or more on a touch screen.
   main.js measures the overlays and moves the projection centre, so the
   sheet never covers the middle of the view.
     grep -n 'TOUCH'      target and text sizes for any touch screen
     grep -n 'PHONE'      the phone block (PHONE in main.js)
     grep -n 'LANDSCAPE'  the landscape overrides
     grep -n 'WALKPAD'    the stick and the jump and fly buttons
     grep -n 'saver'      the screensaver mode

   An element with the hidden attribute must have no display rule of its
   own; the first rule below wins over all of them.
   ========================================================================== */
[hidden]{display:none!important}
:root{
  --bg:#0b0d12; --bg2:#14171f; --ink:#e6e1d8; --dim:#9a958c; --faint:#2e2f36;
  --line:rgba(240,220,190,0.12); --line-b:rgba(240,220,190,0.24);
  --warm:#f0a35e; --cool:#8fb8e8; --panel-w:320px; --dock-h:0px}
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html{background:var(--bg);overflow:hidden}
html,body{height:100%}
body{width:100%;background:var(--bg);color:var(--ink);font-family:var(--sci-sans);-webkit-font-smoothing:antialiased;overscroll-behavior:none}
button,input{font-family:inherit;touch-action:manipulation;-webkit-tap-highlight-color:transparent}
a{color:var(--warm)}

#stage{position:fixed;inset:0}
#view{position:absolute;inset:0;width:100%;height:100%;display:block;touch-action:none;outline:none;background:#a8b4c0}
body.locked #view{cursor:none}

.topbar{
  position:fixed;top:0;left:0;right:var(--panel-w);z-index:30;display:flex;align-items:center;gap:12px;
  height:52px;padding:0 18px;pointer-events:none}
body.panel-closed .topbar{right:0}
.brand{font-family:var(--sci-serif);font-size:1.12rem;color:#fff8ee;white-space:nowrap;text-shadow:0 1px 6px rgba(0,0,0,0.55)}
.mock-badge{
  pointer-events:auto;font:600 0.72rem var(--sci-sans);color:#1b1206;background:var(--warm);border-radius:6px;padding:3px 8px;
  white-space:nowrap}
.tb-btn{
  pointer-events:auto;margin-left:auto;height:34px;width:34px;border:1px solid var(--line-b);border-radius:9px;
  background:rgba(14,16,22,0.75);color:var(--ink);font-size:0.9rem;cursor:pointer;visibility:hidden}
body.panel-closed .tb-btn{visibility:visible}
.tb-btn:hover{border-color:var(--warm);color:var(--warm)}

.boot{
  position:fixed;left:50%;top:45%;transform:translate(-50%,-50%);z-index:25;padding:10px 16px;
  border:1px solid var(--line);border-radius:10px;background:rgba(14,16,22,0.88);font-size:0.86rem;color:var(--dim);max-width:80vw;text-align:center}
.boot.err{color:#ff8a7a;border-color:rgba(255,120,100,0.4)}
.hint-line{
  position:fixed;left:18px;bottom:34px;z-index:20;font-size:0.76rem;color:#f4efe6;pointer-events:none;
  text-shadow:0 1px 4px rgba(0,0,0,0.7)}
.held-note{
  position:fixed;left:50%;top:22%;transform:translateX(-50%);z-index:22;padding:6px 12px;border-radius:8px;
  background:rgba(14,16,22,0.8);font-size:0.8rem;color:var(--ink);pointer-events:none}
.credit-bar{position:fixed;left:18px;bottom:10px;z-index:20;font-size:0.72rem;color:#e8e2d8;text-shadow:0 1px 4px rgba(0,0,0,0.7)}
.credit-bar a{color:#ffd6a8}
.crosshair{display:none;position:fixed;left:50%;top:50%;width:6px;height:6px;margin:-3px 0 0 -3px;border-radius:50%;
  background:rgba(255,255,255,0.85);box-shadow:0 0 0 1px rgba(0,0,0,0.4);z-index:15;pointer-events:none}
body.mode-walk .crosshair{display:block}

/* ---- panel (desktop: a drawer on the right edge) ---- */
.panel{
  position:fixed;top:0;right:0;bottom:0;width:var(--panel-w);z-index:35;overflow-y:auto;
  background:rgba(12,13,18,0.95);border-left:1px solid var(--line-b);padding:14px 18px 24px;
  transform:translateX(100%);transition:transform 0.28s cubic-bezier(0.4,0,0.2,1);overscroll-behavior:contain}
.panel.open{transform:translateX(0)}
.close{
  position:absolute;top:12px;right:12px;width:30px;height:30px;border:1px solid var(--line);border-radius:7px;
  background:transparent;color:var(--dim);cursor:pointer}
.close:hover{color:var(--warm);border-color:var(--warm)}
.grip{display:none}
.sec{padding:12px 0;border-bottom:1px solid var(--line)}
.sec:last-child{border-bottom:0}
.title{font-family:var(--sci-serif);font-size:1.2rem;font-weight:500;margin-right:40px}
.meta{font-size:0.78rem;color:var(--dim);margin-top:4px;line-height:1.5}
.sec-label{font-size:0.74rem;font-weight:600;color:var(--dim);margin-bottom:8px;letter-spacing:0.02em}
.btn{
  height:32px;padding:0 12px;border:1px solid var(--line-b);border-radius:8px;background:var(--bg2);color:var(--ink);
  font-size:0.8rem;cursor:pointer;white-space:nowrap}
.btn:hover{border-color:var(--warm);color:var(--warm)}
.seg{display:flex;height:34px;border:1px solid var(--line-b);border-radius:9px;overflow:hidden}
.seg button{flex:1;min-width:0;border:0;border-right:1px solid var(--line);background:var(--bg2);color:var(--dim);font-size:0.8rem;cursor:pointer}
.seg button:last-child{border-right:0}
.seg button.on{background:rgba(240,163,94,0.16);color:var(--warm)}
.row{display:flex;align-items:center;gap:8px;margin-bottom:10px}
.lbl{font-size:0.78rem;color:var(--dim)}
.num{flex:1;min-width:0;height:32px;padding:0 8px;border:1px solid var(--line-b);border-radius:8px;background:var(--bg2);color:var(--ink);font:0.8rem var(--sci-mono)}
.slider{display:grid;grid-template-columns:1fr auto;align-items:center;gap:2px 8px;margin-top:8px}
.slider label{font-size:0.78rem}
.slider output{font:0.72rem var(--sci-mono);color:var(--dim);font-variant-numeric:tabular-nums}
.slider input{grid-column:1 / 3;width:100%;accent-color:var(--warm)}
.stats{font:0.74rem/1.5 var(--sci-mono);color:var(--ink);font-variant-numeric:tabular-nums}
.keys dl{display:grid;grid-template-columns:auto 1fr;gap:3px 12px;font-size:0.76rem}
.keys dt{font-family:var(--sci-mono);color:var(--warm)}
.keys dd{color:var(--dim)}
.credits p{font-size:0.76rem;line-height:1.6;color:var(--dim);margin-bottom:6px}

.dock{display:none}

/* WALKPAD: the stick and the buttons show in Walk mode on a touch screen */
.touch{display:none}
body.touch-walk .touch{display:block}
body.touch-walk .crosshair{display:block}
.stick{
  position:fixed;left:calc(18px + env(safe-area-inset-left));bottom:calc(var(--dock-h) + 22px);z-index:28;width:132px;height:132px;
  border-radius:50%;border:1px solid rgba(255,255,255,0.35);background:rgba(10,12,16,0.28);touch-action:none}
.knob{position:absolute;left:50%;top:50%;width:56px;height:56px;margin:-28px 0 0 -28px;border-radius:50%;
  background:rgba(255,240,220,0.75);box-shadow:0 2px 8px rgba(0,0,0,0.4);pointer-events:none}
.tbtn{
  position:fixed;right:calc(18px + env(safe-area-inset-right));z-index:28;width:64px;height:64px;border-radius:50%;
  border:1px solid rgba(255,255,255,0.4);background:rgba(10,12,16,0.42);color:#fff;font-size:1.4rem;touch-action:none}
.tbtn.jump{bottom:calc(var(--dock-h) + 30px)}
.tbtn.fly{bottom:calc(var(--dock-h) + 110px);width:52px;height:52px;font-size:1.1rem;right:calc(24px + env(safe-area-inset-right))}
.tbtn.on{border-color:var(--warm);color:var(--warm)}
body.touch-walk .hint-line{bottom:calc(var(--dock-h) + 170px)}

/* TOUCH. Any touch screen or narrow window: every target is 44px or more,
   and all text is 11px or more. */
@media (pointer:coarse), (max-width:768px){
  .tb-btn{height:44px;width:44px}
  .btn{height:44px;font-size:0.82rem}
  .num{height:44px}
  .seg{height:44px}
  .close{width:44px;height:44px;top:4px;right:4px}
  .slider input{-webkit-appearance:none;appearance:none;height:40px;background:transparent}
  .slider input::-webkit-slider-runnable-track{height:6px;border-radius:3px;background:var(--faint)}
  .slider input::-webkit-slider-thumb{-webkit-appearance:none;width:26px;height:26px;margin-top:-10px;border-radius:50%;background:var(--warm);border:3px solid #1a1410}
  .slider input::-moz-range-track{height:6px;border-radius:3px;background:var(--faint)}
  .slider input::-moz-range-thumb{width:22px;height:22px;border-radius:50%;background:var(--warm);border:3px solid #1a1410}
  .meta,.sec-label,.slider output,.stats,.keys dl,.credits p,.hint-line,.credit-bar,.mock-badge{font-size:0.78rem}
}

/* PHONE. The query matches PHONE in main.js. */
@media (max-width:768px), (max-height:500px) and (pointer:coarse){
  :root{--dock-h:calc(64px + env(safe-area-inset-bottom))}
  .topbar{right:0;height:calc(52px + env(safe-area-inset-top));padding:env(safe-area-inset-top) calc(12px + env(safe-area-inset-right)) 0 calc(14px + env(safe-area-inset-left));gap:10px}
  .brand{font-size:1rem}
  .tb-btn{display:none}
  .credit-bar,.keys{display:none}
  .hint-line{bottom:calc(var(--dock-h) + 10px);left:14px;right:14px}

  .dock{
    display:flex;position:fixed;left:0;right:0;bottom:0;z-index:45;gap:6px;align-items:center;
    padding:8px calc(8px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left));
    background:rgba(10,11,15,0.95);border-top:1px solid var(--line-b)}
  .dock > button{flex:0 0 48px;height:48px;border:1px solid var(--line-b);border-radius:12px;background:var(--bg2);color:var(--ink);font-size:1.15rem;cursor:pointer}
  .dock > button.on{border-color:var(--warm);color:var(--warm)}
  .dock .seg{flex:1;height:48px;border-radius:12px}
  .dock .seg button{font-size:0.82rem}

  /* The panel is a bottom sheet above the dock. */
  .panel{
    top:auto;left:0;right:0;bottom:var(--dock-h);width:auto;
    height:min(46vh,520px);height:min(46dvh,520px);
    border-left:0;border-top:1px solid var(--line-b);border-radius:18px 18px 0 0;
    padding:0 calc(16px + env(safe-area-inset-right)) 24px calc(16px + env(safe-area-inset-left));
    transform:translateY(calc(100% + var(--dock-h)));transition:transform 0.3s cubic-bezier(0.4,0,0.2,1),height 0.3s cubic-bezier(0.4,0,0.2,1)}
  .panel.open{transform:translateY(0)}
  .panel.full{height:calc(100vh - var(--dock-h) - 40px);height:calc(100dvh - var(--dock-h) - 40px)}
  #panelClose{display:none}
  .grip{
    display:flex;position:sticky;top:0;z-index:2;justify-content:center;align-items:center;height:44px;margin:0 -16px;
    background:linear-gradient(180deg,rgba(12,13,18,1) 65%,rgba(12,13,18,0));touch-action:none;cursor:grab}
  .grip span{width:46px;height:5px;border-radius:3px;background:var(--dim);opacity:0.6}
  /* the walk pad stays clear of an open sheet: the sheet sits over it */
  body:not(.panel-closed) .touch{display:none}
}

/* LANDSCAPE phone. The panel is a drawer on the right edge. The dock is a
   tab at the lower left. The topbar is hidden. */
@media (max-height:500px) and (orientation:landscape){
  .topbar{display:none}
  .dock{right:auto;width:min(420px,56vw);border-right:1px solid var(--line-b);border-radius:0 16px 0 0}
  .panel,.panel.full{
    top:0;bottom:0;left:auto;right:0;width:min(44vw,360px);height:auto;
    border-top:0;border-left:1px solid var(--line-b);border-radius:0;
    padding:0 calc(14px + env(safe-area-inset-right)) 20px 14px;
    transform:translateX(100%)}
  .panel.open{transform:translateX(0)}
  .grip{display:none}
  #panelClose{display:block;position:sticky;top:8px;margin:8px 0 0 auto;z-index:2;background:var(--bg2)}
  .stick{bottom:calc(var(--dock-h) + 14px);width:116px;height:116px}
  .tbtn.fly{bottom:calc(14px + 80px)}
  .tbtn.jump{bottom:14px}
  body.touch-walk .hint-line{display:none}
}

/* screensaver (lib/screensaver.js, saver.js): only the canvas shows */
html.sn-saver .topbar,html.sn-saver .panel,html.sn-saver .dock,html.sn-saver .hint-line,html.sn-saver .credit-bar,
html.sn-saver .boot,html.sn-saver .touch,html.sn-saver .crosshair,html.sn-saver .held-note{visibility:hidden}
