:root {
  --glass: rgba(18, 18, 24, 0.55);
  --glass-border: rgba(255, 233, 201, 0.18);
  --accent: #ffe9c9;
  --ink: #f4ecd8;
}

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #0d0d10;
  font-family: 'Bricolage Grotesque', sans-serif;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

#scene-container { position: fixed; inset: 0; cursor: grab; }
#scene-container:active { cursor: grabbing; }

/* HUD */
#hud {
  position: fixed; top: 16px; left: 16px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 10; pointer-events: none;
}
#title-badge {
  font-weight: 800; font-size: 20px; letter-spacing: 0.5px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  padding: 8px 16px; border-radius: 14px;
}
#counter {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; letter-spacing: 1px;
  color: rgba(244, 236, 216, 0.65);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  padding: 5px 12px; border-radius: 10px; width: fit-content;
}

/* controls hint */
#controls-hint {
  position: fixed; bottom: 16px; left: 50%;
  transform: translateX(-50%);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; letter-spacing: 0.5px;
  color: rgba(244, 236, 216, 0.8);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  padding: 8px 16px; border-radius: 12px;
  z-index: 10; text-align: center;
  transition: opacity 1s ease; white-space: nowrap;
}
#controls-hint b { color: var(--accent); font-weight: 700; }
#controls-hint.fade { opacity: 0; }
#controls-hint.hidden { display: none; }
.hint-touch { display: none; }
body.touch .hint-desktop { display: none; }
body.touch .hint-touch { display: inline; }

/* shuffle btn */
#shuffle-btn {
  position: fixed; top: 16px; right: 16px;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800; font-size: 15px;
  color: #0d0d10;
  background: var(--accent);
  border: none; border-radius: 14px;
  padding: 10px 18px; cursor: pointer;
  box-shadow: 0 6px 20px rgba(255, 233, 201, 0.25);
  z-index: 20; transition: transform 0.2s, box-shadow 0.2s;
}
#shuffle-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(255, 233, 201, 0.4); }
#shuffle-btn:active { transform: scale(0.96); }
#shuffle-btn.spin { animation: wobble 0.6s ease; }
@keyframes wobble {
  0%,100% { transform: rotate(0); }
  25% { transform: rotate(-8deg); }
  75% { transform: rotate(8deg); }
}

/* touch dpad */
#touch-pad {
  position: fixed; bottom: 70px; right: 16px;
  display: none; flex-direction: column; align-items: center; gap: 6px;
  z-index: 20;
}
body.touch #touch-pad { display: flex; }
.tp-row { display: flex; gap: 6px; }
.tp {
  width: 52px; height: 52px;
  font-size: 20px; color: var(--ink);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-radius: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  user-select: none; touch-action: none;
}
.tp:active { background: var(--accent); color: #0d0d10; }

/* loader */
#loader {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 20px; background: rgba(13, 13, 16, 0.85);
  backdrop-filter: blur(6px);
  transition: opacity 0.5s ease;
}
#loader.hidden { opacity: 0; pointer-events: none; }
.spinner {
  width: 46px; height: 46px;
  border: 3px solid rgba(255, 233, 201, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px; letter-spacing: 1px;
  color: rgba(244, 236, 216, 0.7);
}

/* focus panel */
#focus-panel {
  position: fixed; bottom: -200px; left: 50%;
  transform: translateX(-50%);
  width: min(90vw, 420px);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-radius: 18px; padding: 20px 22px;
  z-index: 30; text-align: center;
  transition: bottom 0.5s cubic-bezier(0.2, 0.9, 0.3, 1);
}
#focus-panel.show { bottom: 24px; }
#focus-title { font-weight: 800; font-size: 22px; margin-bottom: 4px; }
#focus-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; font-style: italic;
  color: rgba(244, 236, 216, 0.65);
  margin-bottom: 14px;
}
#focus-back {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 400; font-size: 14px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--glass-border);
  border-radius: 12px; padding: 8px 18px; cursor: pointer;
  transition: background 0.2s;
}
#focus-back:hover { background: rgba(255, 233, 201, 0.15); }

/* remix link */
#remix-link {
  position: fixed; bottom: 8px; right: 12px;
  z-index: 10;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: 0.5px;
  color: rgba(244, 236, 216, 0.4);
  text-decoration: none;
}
#remix-link:hover { color: var(--accent); }

@media (max-width: 640px) {
  #title-badge { font-size: 16px; }
  #shuffle-btn { font-size: 13px; padding: 8px 14px; }
  #controls-hint { font-size: 10px; bottom: 8px; }
  #remix-link { bottom: 130px; }
}