html, body { margin: 0; height: 100%; background: #000; overflow: hidden; overscroll-behavior: none; }
body { font: 14px/1.4 system-ui, -apple-system, 'Segoe UI', sans-serif; color: #fff; }
body.nocursor { cursor: none; }
#host { position: fixed; inset: 0; touch-action: none; -webkit-user-select: none; user-select: none; }
#host canvas { display: block; width: 100vw; height: 100vh; height: 100dvh; }
#stats {
  position: fixed; top: max(6px, env(safe-area-inset-top)); left: max(6px, env(safe-area-inset-left));
  display: none; padding: 4px 8px; border-radius: 6px; font: 12px/1.3 ui-monospace, monospace;
  background: rgba(0, 0, 0, 0.6); pointer-events: none;
}
button, select {
  font: inherit; color: #fff; background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 8px; padding: 0.45em 0.9em; cursor: pointer;
}
button:hover, select:hover { background: rgba(255, 255, 255, 0.2); }
button:focus-visible, select:focus-visible, li:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
#overlay .wheel li:focus-visible { outline-offset: -2px; border-radius: 8px; }
select option { color: #000; }

/* ---- toast ---- */
#toast {
  position: fixed; left: 50%; bottom: 6vh; transform: translateX(-50%);
  padding: 0.5em 1em; border-radius: 999px; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis;
  background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(6px);
  opacity: 0; transition: opacity 0.4s; pointer-events: none;
}
#toast.on { opacity: 1; }

/* ---- settings overlay ---- */
#overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0; visibility: hidden; transition: opacity 0.35s, visibility 0s linear 0.35s;
}
#overlay.on { opacity: 1; visibility: visible; transition: opacity 0.25s; }
#overlay .panel {
  width: min(92vw, 760px); max-height: 92vh; overflow: auto; box-sizing: border-box;
  padding: 18px 20px; border-radius: 18px;
  background: rgba(10, 10, 10, 0.72); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
#overlay .wheels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
#overlay .wheel h3 {
  margin: 0 0 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.7; text-align: center;
}
#overlay .wheel ul {
  list-style: none; margin: 0; padding: 70px 0; height: 180px; box-sizing: border-box; overflow-y: auto;
  scroll-snap-type: y proximity; scrollbar-width: none;
  border-radius: 10px; background: rgba(255, 255, 255, 0.06);
  -webkit-mask-image: linear-gradient(transparent, #000 18%, #000 82%, transparent);
  mask-image: linear-gradient(transparent, #000 18%, #000 82%, transparent);
}
#overlay .wheel ul::-webkit-scrollbar { display: none; }
#overlay .wheel li {
  padding: 7px 10px; text-align: center; scroll-snap-align: center; cursor: pointer; opacity: 0.7;
  text-transform: lowercase; user-select: none;
}
#overlay .wheel li:hover { opacity: 1; background: rgba(255, 255, 255, 0.08); }
#overlay .wheel li.selected { opacity: 1; font-weight: 600; background: rgba(255, 255, 255, 0.18); border-radius: 8px; }
#overlay .row { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; margin-top: 16px; }
#overlay .row label { display: flex; align-items: center; gap: 6px; margin-right: auto; }
#overlay .info { margin-top: 12px; font-size: 12px; opacity: 0.8; word-break: break-all; }
#overlay .keys { margin-top: 6px; font-size: 11px; opacity: 0.5; }
@media (max-width: 600px) {
  #overlay .wheels { grid-template-columns: repeat(2, 1fr); }
  #overlay .row label { margin-right: 0; width: 100%; }
}

/* ---- photosensitivity notice ---- */
#notice {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.6); z-index: 10;
}
#notice.on { display: flex; }
#notice .card {
  width: min(90vw, 440px); padding: 22px 24px; border-radius: 16px;
  background: rgba(20, 20, 20, 0.95); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}
#notice h2 { margin: 0 0 8px; font-size: 18px; }
#notice p { margin: 0 0 10px; opacity: 0.85; }
#notice button { margin-top: 6px; }

/* ---- loading / error ---- */
#status {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: #ccc; padding: 2em; text-align: center;
}