:root {
  --bg: #0b0d10;
  --fg: #e8eaed;
  --muted: #9aa0a6;
  --accent: #4f8cff;
  --panel: rgba(20, 22, 26, 0.82);
  --border: rgba(255, 255, 255, 0.12);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; background: var(--bg); color: var(--fg);
  font: 15px -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  overflow: hidden; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
#login {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; gap: 14px; padding: 16px;
}
#login h1 { margin: 0; font-weight: 600; letter-spacing: .5px; }
.sub { margin: 0; color: var(--muted); }
#pin {
  width: 200px; font-size: 28px; text-align: center; letter-spacing: 8px;
  padding: 10px; border-radius: 12px; border: 1px solid var(--border);
  background: #15181d; color: var(--fg); -webkit-user-select: text; user-select: text;
}
button {
  font: inherit; color: var(--fg); background: #1f2329; border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 12px;
}
#connect { background: var(--accent); border: none; width: 200px; padding: 12px; font-weight: 600; }
.msg { color: #ff8a80; min-height: 1.2em; margin: 0; }

.logo { width: 72px; height: 72px; border-radius: 16px; }
.hint { color: var(--muted); font-size: 13px; max-width: 300px; text-align: center; line-height: 1.5; margin: 8px 0 0; }

#stage { position: fixed; left: 0; top: 0; width: 100%; height: 100%; background: #000; overflow: hidden; }
#view { position: absolute; inset: 0; transform-origin: 0 0; will-change: transform; }
#video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
#overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 12px;
  align-items: center; justify-content: center; background: rgba(0, 0, 0, .55); pointer-events: none;
}
#overlay[hidden] { display: none; }
#login[hidden], #bar[hidden] { display: none; }
#soundUnlock {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: var(--panel); padding: 12px 18px; white-space: nowrap;
}
.spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .25); border-top-color: #fff; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#touch { position: absolute; inset: 0; touch-action: none; }
#cursor {
  position: absolute; width: 14px; height: 14px; margin: -2px 0 0 -2px; pointer-events: none;
  border-left: 3px solid #fff; border-top: 3px solid #fff; transform: skew(0, 0);
  filter: drop-shadow(0 0 1px #000) drop-shadow(0 0 1px #000); display: none;
}
#stats {
  position: absolute; top: calc(env(safe-area-inset-top) + 8px); left: calc(env(safe-area-inset-left) + 8px);
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 10px; font: 12px/1.5 ui-monospace, Menlo, monospace; white-space: pre; pointer-events: none;
}
#toast {
  position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%);
  background: var(--panel); padding: 10px 16px; border-radius: 10px; opacity: 0;
  transition: opacity .2s; pointer-events: none;
}
#toast.on { opacity: 1; }
#bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  display: flex; flex-wrap: nowrap; gap: 6px; overflow-x: auto; background: var(--panel); border-top: 1px solid var(--border);
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
#bar::-webkit-scrollbar { display: none; }
#bar button { flex: 0 0 auto; padding: 8px 11px; font-size: 14px; }
#bar button:active, #bar button.on { background: var(--accent); }
@media (orientation: landscape) and (pointer: coarse) {
  #bar { gap: 4px; }
  #bar button { padding: 8px; }
}
#showBar {
  position: absolute; right: calc(env(safe-area-inset-right) + 10px); bottom: calc(env(safe-area-inset-bottom) + 10px);
  opacity: .6; padding: 6px 12px;
}
#kbd { position: absolute; left: -1000px; top: 0; width: 10px; height: 10px; opacity: 0; font-size: 16px; }
