* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #05070d;
  --panel: rgba(14, 18, 28, 0.82);
  --line: #1d2735;
  --text: #e8edf5;
  --muted: #8a97a8;
  --accent: #ffb347;
}

html, body { height: 100%; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }

#app { position: fixed; inset: 0; }

#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

#topbar {
  position: absolute; top: 0; left: 0; right: 0; padding: 14px 20px;
  display: flex; align-items: baseline; gap: 16px;
  background: linear-gradient(180deg, rgba(5,7,13,0.7), rgba(5,7,13,0));
  pointer-events: none;
}
#topbar h1 { font-size: 18px; font-weight: 600; letter-spacing: 0.3px; }
#info { color: var(--muted); font-size: 12px; }

#panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: 320px; max-width: 80vw;
  background: var(--panel); backdrop-filter: blur(10px);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 64px 16px 16px;
  overflow-y: auto;
}

/* Sheet bar is desktop-hidden; sheet-body is the scrolling content. */
#sheetBar { display: none; }
.sheet-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.section { margin-bottom: 22px; }
.section h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); margin-bottom: 10px; }

#patterns { list-style: none; display: flex; flex-direction: column; gap: 4px; }
#patterns li {
  padding: 9px 12px; border-radius: 8px; cursor: pointer; font-size: 14px;
  border: 1px solid transparent; transition: background 0.12s, border-color 0.12s;
}
#patterns li:hover { background: rgba(255,255,255,0.04); }
#patterns li.active { background: rgba(255,179,71,0.12); border-color: var(--accent); color: var(--accent); }

#patternName { font-size: 16px; color: var(--text); text-transform: none; letter-spacing: 0; }
#patternDesc { color: var(--muted); font-size: 12px; margin: 4px 0 14px; line-height: 1.4; }

.param { display: grid; grid-template-columns: 96px 1fr 40px; align-items: center;
  gap: 8px; margin-bottom: 10px; }
.param label { font-size: 12px; color: var(--muted); }
.param input[type=range] { width: 100%; accent-color: var(--accent); }
.param input[type=color] { width: 100%; height: 26px; border: none; background: none; cursor: pointer; }
.param select { width: 100%; background: #0d1320; color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; padding: 4px; }
.param .val { font-size: 11px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

#panel footer { margin-top: auto; color: var(--muted); }
#panel footer small { font-size: 11px; line-height: 1.5; }

@media (max-width: 640px) {
  /* Fountain fills the screen; panel becomes a slide-up bottom sheet. */
  #panel {
    top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-width: 100%;
    height: 78vh;                 /* expanded height */
    border-left: none; border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
    padding: 0;
    transform: translateY(calc(100% - var(--bar-h, 64px)));  /* collapsed: only bar shows */
    transition: transform 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
    overflow: hidden;
  }
  #panel.open { transform: translateY(0); }

  #sheetBar {
    display: flex; align-items: center; gap: 12px;
    width: 100%; height: var(--bar-h, 64px); flex: 0 0 auto;
    padding: 0 18px; background: none; border: none; color: var(--text);
    cursor: pointer; text-align: left; -webkit-tap-highlight-color: transparent;
  }
  #sheetBar .grip {
    position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
    width: 40px; height: 4px; border-radius: 2px; background: var(--line);
  }
  #sheetBar .bar-label { display: flex; flex-direction: column; flex: 1; }
  #sheetBar .bar-now { font-size: 16px; font-weight: 600; }
  #sheetBar .bar-hint { font-size: 11px; color: var(--muted); }
  #sheetBar .chev { color: var(--muted); transition: transform 0.28s; font-size: 13px; }
  #panel.open #sheetBar .chev { transform: rotate(180deg); }

  .sheet-body {
    flex: 1; min-height: 0; overflow-y: auto;
    padding: 4px 16px 20px; -webkit-overflow-scrolling: touch;
  }

  /* Bigger touch targets on mobile */
  #patterns li { padding: 14px 14px; font-size: 16px; }
  .param { grid-template-columns: 92px 1fr 38px; margin-bottom: 16px; }
  .param input[type=range] { height: 28px; }
  .param input[type=color] { height: 34px; }
  .param select { padding: 8px; font-size: 15px; }

  #topbar { padding: 10px 14px; background: linear-gradient(180deg, rgba(5,7,13,0.85), rgba(5,7,13,0)); }
  #topbar h1 { font-size: 15px; }
  #info { display: none; }   /* keep the top clean on phones */
}
