:root {
  --bg: #0a1014;
  --glass: rgba(16, 26, 30, 0.55);
  --glass-strong: rgba(12, 20, 24, 0.82);
  --stroke: rgba(180, 220, 210, 0.16);
  --text: #e8f2ee;
  --muted: #9fb3ad;
  --accent: #7fd1b0;
  --accent-2: #b6e2c9;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

#app { position: fixed; inset: 0; }
#app canvas { display: block; }

.hidden { display: none !important; }

/* ---------- Crosshair ---------- */
#crosshair {
  position: fixed;
  left: 50%; top: 50%;
  width: 7px; height: 7px;
  margin: -3.5px 0 0 -3.5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.32);
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  z-index: 30;
}

/* ---------- Overlay / Start ---------- */
#overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(40, 80, 70, 0.35), transparent 60%),
    linear-gradient(180deg, #0c151a 0%, #070b0e 100%);
  z-index: 50;
  transition: opacity 1.1s ease;
}
#overlay.fade { opacity: 0; pointer-events: none; }

.overlay-inner {
  text-align: center;
  padding: 32px;
  max-width: 460px;
}
#overlay h1 {
  font-size: 64px;
  letter-spacing: 18px;
  margin: 0 0 6px;
  font-weight: 300;
  text-indent: 18px;
  background: linear-gradient(180deg, #eafff6, #8fc9b3);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 2px 30px rgba(127, 209, 176, 0.25);
}
.subtitle {
  color: var(--muted);
  letter-spacing: 3px;
  font-size: 13px;
  margin: 0 0 34px;
  text-transform: uppercase;
}

/* loader */
.loader-bar {
  width: 240px; height: 3px;
  margin: 0 auto 14px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px; overflow: hidden;
}
#loader-fill {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.3s ease;
}
#loader-text { color: var(--muted); font-size: 13px; letter-spacing: 1px; }

/* start actions */
#start-actions { animation: rise 0.7s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px);} to {opacity:1; transform:none;} }

button.primary {
  appearance: none; border: 0; cursor: pointer;
  padding: 14px 30px; border-radius: 999px;
  font-size: 16px; letter-spacing: 4px; color: #06120d;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow: 0 8px 30px rgba(127, 209, 176, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
button.primary:hover { transform: translateY(-2px); box-shadow: 0 12px 38px rgba(127, 209, 176, 0.5); }
button.primary:active { transform: translateY(0); }

#vr-slot { margin-top: 14px; min-height: 0; }
#vr-slot button {
  position: static !important;
  margin: 14px auto 0 !important;
  transform: none !important;
}

.hint-list {
  list-style: none; padding: 0; margin: 26px 0 0;
  color: var(--muted); font-size: 13px; line-height: 2;
}
.hint-list b { color: var(--accent-2); font-weight: 600; }

/* ---------- Control panel ---------- */
#ui {
  position: fixed; top: 16px; left: 16px;
  width: 248px;
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--stroke);
  border-radius: 16px;
  box-shadow: var(--shadow);
  z-index: 40;
  overflow: hidden;
  animation: rise 0.6s ease both;
}
.ui-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px;
  font-size: 13px; letter-spacing: 2px;
  border-bottom: 1px solid var(--stroke);
}
.ui-head .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}
#ui-title { flex: 1; }
#ui-collapse {
  appearance: none; background: transparent; border: 0; cursor: pointer;
  color: var(--muted); font-size: 18px; line-height: 1; padding: 0 4px;
}
.ui-body { padding: 6px 14px 14px; max-height: 78vh; overflow-y: auto; }
#ui.collapsed .ui-body { display: none; }

.group { padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
.group:last-child { border-bottom: 0; }
.group h3 {
  margin: 0 0 10px; font-size: 11px; font-weight: 600;
  letter-spacing: 2px; color: var(--muted); text-transform: uppercase;
}

/* segmented buttons */
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seg button {
  appearance: none; cursor: pointer;
  padding: 9px 0; font-size: 14px;
  color: var(--text);
  background: rgba(255,255,255,0.05);
  border: 1px solid transparent;
  border-radius: 10px;
  transition: all 0.18s ease;
}
.seg button:hover { background: rgba(127,209,176,0.14); }
.seg button.active {
  background: linear-gradient(180deg, rgba(127,209,176,0.28), rgba(127,209,176,0.12));
  border-color: rgba(127,209,176,0.5);
  color: #fff;
  box-shadow: 0 0 0 1px rgba(127,209,176,0.2) inset;
}

/* rows / inputs */
.row { display: flex; align-items: center; gap: 10px; margin: 4px 0; }
.row .ico { font-size: 14px; width: 18px; text-align: center; }
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 4px;
  background: rgba(255,255,255,0.14);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent-2);
  border: 2px solid #06120d;
  box-shadow: 0 0 10px rgba(127,209,176,0.6);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent-2); border: 2px solid #06120d; cursor: pointer;
}

.check {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text); cursor: pointer; margin: 8px 0 2px;
}
.check input { accent-color: var(--accent); width: 15px; height: 15px; }

button.ghost {
  appearance: none; cursor: pointer; width: 100%; margin-top: 10px;
  padding: 9px; font-size: 13px; color: var(--accent-2);
  background: rgba(127,209,176,0.08);
  border: 1px solid rgba(127,209,176,0.25); border-radius: 10px;
  transition: background 0.18s ease;
}
button.ghost:hover { background: rgba(127,209,176,0.18); }

/* ---------- bottom hint ---------- */
#hint {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  font-size: 12px; letter-spacing: 1px; color: var(--muted);
  background: var(--glass); padding: 7px 16px; border-radius: 999px;
  border: 1px solid var(--stroke); z-index: 35;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

/* ---------- breathing guide ---------- */
#breathing {
  position: fixed; inset: 0; z-index: 28;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  pointer-events: none;
}
.breath-ring {
  width: 160px; height: 160px; border-radius: 50%;
  border: 1px solid rgba(182, 226, 201, 0.35);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 60px rgba(127, 209, 176, 0.15);
}
.breath-core {
  width: 70px; height: 70px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(214,255,238,0.9), rgba(127,209,176,0.35));
  box-shadow: 0 0 40px rgba(127,209,176,0.5);
  transform: scale(0.55);
  will-change: transform;
}
.breath-label {
  margin-top: 22px; letter-spacing: 8px; font-size: 15px;
  color: rgba(232,242,238,0.85); text-indent: 8px;
}

/* ---------- error banner ---------- */
#error {
  position: fixed; left: 50%; top: 18px; transform: translateX(-50%);
  max-width: 90vw; z-index: 99;
  background: rgba(60, 18, 20, 0.92);
  border: 1px solid rgba(255, 120, 120, 0.4);
  color: #ffd9d9; padding: 12px 18px; border-radius: 12px;
  font-size: 13px; line-height: 1.5; box-shadow: var(--shadow);
}

/* mobile tweaks */
@media (max-width: 640px) {
  #overlay h1 { font-size: 48px; letter-spacing: 12px; }
  #ui { width: 210px; top: 10px; left: 10px; }
}

/* touch joystick */
#joystick {
  position: fixed; z-index: 36;
  width: 120px; height: 120px; border-radius: 50%;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--stroke);
  display: none;
}
#joystick .nub {
  position: absolute; left: 50%; top: 50%;
  width: 52px; height: 52px; margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(214,255,238,0.85), rgba(127,209,176,0.4));
  box-shadow: 0 0 20px rgba(127,209,176,0.4);
}
body.touch #joystick { display: block; }
