:root {
  --bg: #000;
  --panel: rgba(18, 20, 24, 0.82);
  --panel-solid: #14161a;
  --fg: #f2f4f8;
  --muted: #aab2c0;
  --accent: #4f9dff;
  --accent-2: #2f7d32;
  --radius: 12px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

#gl {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
}

/* ---------- bars ---------- */
.bar {
  position: fixed;
  left: 0; right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 12px 10px;
  transition: opacity .25s ease, transform .25s ease;
}
.bar.top {
  top: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,.72), rgba(0,0,0,0));
  flex-wrap: wrap;
}
.bar.bottom {
  bottom: 0;
  padding: 10px 12px max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(0,0,0,.72), rgba(0,0,0,0));
}
.group { display: flex; align-items: center; gap: 8px; }
.group.right { margin-left: auto; }

/* ---------- buttons & selects ---------- */
.btn {
  appearance: none;
  border: 1px solid rgba(255,255,255,.16);
  background: var(--panel);
  color: var(--fg);
  font-size: 15px;
  line-height: 1;
  padding: 10px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  user-select: none;
}
.btn:hover { border-color: rgba(255,255,255,.32); }
.btn.primary { background: var(--accent); border-color: transparent; font-weight: 600; }
.btn.icon { padding: 10px 12px; font-size: 18px; min-width: 44px; text-align: center; }
.btn.toggle[aria-pressed="true"],
.btn.icon[aria-pressed="true"] { background: var(--accent); border-color: transparent; }

.sel { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.sel select {
  appearance: none;
  background: var(--panel);
  color: var(--fg);
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 14px;
}

/* ---------- transport ---------- */
#seek { flex: 1; height: 4px; accent-color: var(--accent); }
.time { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); min-width: 92px; text-align: right; }

input[type="range"] { accent-color: var(--accent); }

/* ---------- settings panel ---------- */
.panel {
  position: fixed;
  top: 64px; right: 12px;
  z-index: 20;
  width: min(320px, calc(100vw - 24px));
  background: var(--panel-solid);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 16px;
  padding: 14px 16px;
  display: none;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
}
.panel.open { display: block; }
.panel h3 { margin: 2px 0 12px; font-size: 15px; }
.panel .row { display: flex; align-items: center; gap: 10px; margin: 10px 0; font-size: 14px; }
.panel .row span { flex: 1; color: var(--muted); }
.panel .row.sub span { padding-left: 12px; font-size: 13px; }
.panel .row input[type="range"] { flex: 1.4; }
.panel .row em { width: 38px; text-align: right; color: var(--fg); font-style: normal; }
.panel .note { font-size: 12px; color: var(--muted); line-height: 1.5; margin: 12px 0 2px; }
.panel #gyroBtn { width: 100%; margin-top: 6px; }

/* ---------- gate ---------- */
.gate {
  position: fixed; inset: 0; z-index: 40;
  display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px);
}
.gate.show { display: flex; }
.gate-card { text-align: center; padding: 28px 34px; }
.gate-icon { font-size: 64px; }
.gate-label { font-size: 22px; font-weight: 700; margin-top: 10px; }
.gate-sub { font-size: 14px; color: var(--muted); margin-top: 6px; }

/* ---------- status toast ---------- */
.status {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(8px);
  z-index: 30;
  max-width: min(560px, calc(100vw - 32px));
  background: var(--panel-solid);
  border: 1px solid rgba(255,255,255,.14);
  color: var(--fg);
  padding: 10px 14px; border-radius: 12px; font-size: 13px; line-height: 1.45;
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
  text-align: center;
}
.status.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- VR mode ---------- */
.vr-hint {
  position: fixed; top: 8px; left: 50%; transform: translateX(-50%);
  z-index: 30; font-size: 12px; color: var(--muted);
  background: rgba(0,0,0,.4); padding: 4px 10px; border-radius: 8px;
  display: none;
}
body.vr .bar,
body.vr .panel { display: none !important; }
body.vr .vr-hint { display: block; }
body.vr #seek { display: none; }

/* center divider line for the two eyes */
body.vr::after {
  content: ""; position: fixed; top: 0; bottom: 0; left: 50%;
  width: 1px; background: rgba(255,255,255,.08); z-index: 5; pointer-events: none;
}

/* ---------- auto-hide ---------- */
body.hidden-ui .bar { opacity: 0; pointer-events: none; }
body.hidden-ui .bar.top { transform: translateY(-12px); }
body.hidden-ui .bar.bottom { transform: translateY(12px); }
