* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #8fb0cf;
  font-family: -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif; color: #eef2f6;
  -webkit-tap-highlight-color: transparent;
}
canvas { display: block; touch-action: none; }

#loading {
  position: absolute; inset: 0; display: grid; place-items: center; font-size: 15px; letter-spacing: .5px;
  background: linear-gradient(#6f98c4, #b9cfe0); transition: opacity .6s; z-index: 5; color: #fff;
}
body.ready #loading { opacity: 0; pointer-events: none; }

.glass {
  position: absolute;
  background: rgba(14, 20, 28, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}

#panel { left: 18px; top: 18px; width: 292px; padding: 16px 18px 14px; z-index: 3; }
.head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.title { font-size: 21px; font-weight: 800; letter-spacing: .3px; }
.title::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #e30a17; margin-right: 8px; vertical-align: 3px; box-shadow: 0 0 0 2px rgba(255,255,255,.7); }
.subtitle { font-size: 12px; opacity: .7; margin-top: 2px; }
button.icon { display: none; background: rgba(255,255,255,.1); border: 0; color: #fff; width: 32px; height: 32px; border-radius: 10px; font-size: 16px; cursor: pointer; transition: transform .25s; }

.slider-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.val { font-variant-numeric: tabular-nums; color: #ffd0d3; font-weight: 600; }
.info { font-size: 11.5px; opacity: .75; margin: -8px 0 12px; }

input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, #e30a17 var(--p, 0%), rgba(255,255,255,.18) var(--p, 0%));
  outline: none; margin: 6px 0 14px; touch-action: pan-y;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 3px solid #e30a17; cursor: grab; box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid #e30a17; }

.btn {
  width: 100%; padding: 9px 0; border: 1px solid rgba(255,255,255,.18); border-radius: 10px; cursor: pointer;
  font-weight: 700; font-size: 13px; color: #fff; background: rgba(255, 190, 90, .16); transition: background .2s;
}
.btn:hover { background: rgba(255, 190, 90, .3); }
.toggles { display: flex; flex-direction: column; gap: 6px; margin: 12px 0 8px; font-size: 13px; }
.toggles input { accent-color: #e30a17; }
.stats { font-size: 10.5px; opacity: .55; border-top: 1px solid rgba(255,255,255,.1); padding-top: 8px; font-variant-numeric: tabular-nums; }

#cursor {
  position: absolute; width: 22px; height: 22px; pointer-events: none; display: none; z-index: 10;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M3 2l7 19 2.6-7.4L20 11z' fill='white' stroke='black' stroke-width='1.5' stroke-linejoin='round'/></svg>") no-repeat;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.6));
}
#cursor.down { transform: scale(.85); }

/* ── phones (portrait): bottom sheet, collapsible ── */
@media (max-width: 700px) {
  #panel {
    left: 8px; right: 8px; top: auto; bottom: calc(8px + env(safe-area-inset-bottom));
    width: auto; padding: 10px 14px 8px; border-radius: 14px;
  }
  .head { margin-bottom: 6px; align-items: center; }
  .title { font-size: 16px; }
  .subtitle { font-size: 11px; }
  button.icon { display: block; }
  .slider-label { font-size: 12.5px; }
  input[type=range] { height: 8px; margin: 8px 0 12px; }
  input[type=range]::-webkit-slider-thumb { width: 26px; height: 26px; }
  .more { display: grid; grid-template-columns: 1fr 1fr; column-gap: 14px; }
  .more .btn, .more .toggles { grid-column: 1 / -1; }
  .toggles { flex-direction: row; flex-wrap: wrap; gap: 4px 14px; margin: 10px 0 6px; font-size: 12.5px; }
  .stats { display: none; }
  body.collapsed .more { display: none; }
  body.collapsed button.icon { transform: rotate(180deg); }
}
/* landscape phones: slim side panel */
@media (max-height: 500px) and (min-width: 701px) {
  #panel { width: 240px; padding: 10px 12px; top: 8px; left: 8px; max-height: calc(100% - 16px); overflow-y: auto; }
  .subtitle, .stats { display: none; }
  .title { font-size: 15px; }
  input[type=range] { margin: 4px 0 8px; }
  .toggles { margin: 8px 0 0; gap: 3px 12px; font-size: 12px; flex-direction: row; flex-wrap: wrap; }
  .slider-label { font-size: 12px; }
  .info { margin: -4px 0 8px; font-size: 11px; }
  .btn { padding: 6px 0; }
}
