html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #9cc4e4;
  font-family: system-ui, sans-serif;
  touch-action: none;           /* no page scroll / pinch-zoom; the canvas and touch controls handle gestures */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#title {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 20px);
  left: calc(env(safe-area-inset-left) + 20px);
  color: #fff;
  text-shadow: 0 1px 8px rgba(40, 60, 90, 0.35);
  pointer-events: none;
}

#title h1 {
  margin: 0;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 22px;
  font-weight: 600;
}

#title p {
  margin: 4px 0 0;
  font-size: 12px;
  opacity: 0.8;
}

#panel {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom) + 20px);
  left: 50%;
  transform: translateX(-50%);
  box-sizing: border-box;
  max-width: calc(100% - 40px);
  width: max-content;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 16px;
  align-items: center;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 16px;
  color: #fff;
}

#panel .group {
  display: flex;
  gap: 6px;
  align-items: center;
}

#panel .group > span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.75;
}

#panel button {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}

#panel button:hover {
  background: rgba(255, 255, 255, 0.18);
}

#panel button:disabled {
  opacity: 0.4;
  cursor: default;
  background: transparent;
}

#panel .more {
  display: contents;
}

#panel .toggle {
  display: none;
}

#panel button[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.9);
  color: #2b3a55;
}

#panel button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

#panel input[type="range"] {
  width: 96px;
  accent-color: #ffffff;
  cursor: pointer;
  margin: 0;
}

#panel output {
  font-size: 13px;
  min-width: 2ch;
  font-variant-numeric: tabular-nums;
}

#panel input[type="range"]:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 4px;
}

#loading {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  transition: opacity 0.6s;
}

#loading.hidden {
  opacity: 0;
  pointer-events: none;
}

/* start screen: title, quality picker, Start */
#start {
  display: grid;
  gap: 12px;
  width: min(340px, calc(100vw - 32px));
  box-sizing: border-box;
  padding: 18px;
  background: rgba(40, 60, 95, 0.28);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 18px;
  text-align: center;
}

#start h2 {
  margin: 0;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 24px;
  font-weight: 600;
}

#quality {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

#start button {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 12px;
  padding: 8px 10px;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

#quality small {
  display: block;
  font-size: 11px;
  opacity: 0.8;
}

#start button[aria-pressed="true"],
#start #go {
  background: rgba(255, 255, 255, 0.9);
  color: #2b3a55;
}

#start #go {
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  padding: 10px;
}

#start button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* touch controls: coarse pointers only */
#touch {
  display: none;
}

#stick,
#jump {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom) + 24px);
  touch-action: none;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
}

#stick {
  left: calc(env(safe-area-inset-left) + 24px);
  width: 120px;
  height: 120px;
}

#stick > div {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.75);
  pointer-events: none;
}

#jump {
  right: calc(env(safe-area-inset-right) + 24px);
  width: 76px;
  height: 76px;
  color: #fff;
  font: 600 14px system-ui, sans-serif;
}

#jump:active {
  background: rgba(255, 255, 255, 0.45);
}

@media (pointer: coarse) {
  #touch {
    display: block;
  }
}

/* phones / touch / small windows: hint + compact panel at the top, the rest folds behind the toggle */
@media (pointer: coarse), (max-width: 760px), (max-height: 500px) {
  #title {
    top: calc(env(safe-area-inset-top) + 8px);
    left: calc(env(safe-area-inset-left) + 12px);
    right: calc(env(safe-area-inset-right) + 12px);
  }

  #title h1 {
    display: none;
  }

  #title p {
    margin: 0;
    font-size: 11px;
  }

  #panel {
    top: calc(env(safe-area-inset-top) + 28px);
    bottom: auto;
    max-width: calc(100% - 16px);
    gap: 6px;
    padding: 6px 8px;
    border-radius: 14px;
  }

  #panel .group > span {
    display: none;
  }

  #panel .group {
    gap: 4px;
  }

  #panel button {
    padding: 5px 9px;
    font-size: 12px;
  }

  #panel .toggle {
    display: inline-block;
  }

  #panel .more {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    width: 100%;
  }

  #panel.collapsed .more {
    display: none;
  }

  #panel input[type="range"] {
    width: 80px;
  }
}
