:root {
  --bg-top: #2a2d45;
  --bg-bottom: #14151f;
  --text: #f4f1ea;
  --bubble: rgba(20, 21, 31, 0.78);
  --accent: #e8b65a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: linear-gradient(var(--bg-top), var(--bg-bottom));
  color: var(--text);
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  opacity: 0;
  transition: opacity 0.9s ease;
}

#stage.visible { opacity: 1; }

#subtitle {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(92vw, 720px);
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--bubble);
  font-size: clamp(16px, 4.2vw, 22px);
  line-height: 1.6;
  backdrop-filter: blur(6px);
}

#status {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  right: 12px;
  font-size: 12px;
  opacity: 0.6;
}

/* ---- 接続の画面 ---- */
#connect {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.6s ease;
}

#connect.hidden { opacity: 0; pointer-events: none; }

#connect .ring {
  width: 96px;
  height: 96px;
  margin-bottom: 8px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  opacity: 0.5;
}

#connect.connecting .ring { animation: pulse 1.6s ease-out infinite; }
#connect.connected .ring { opacity: 1; box-shadow: 0 0 24px var(--accent); transition: box-shadow 0.4s ease, opacity 0.4s ease; }
#connect.error .ring { border-color: #c87a7a; }

#connect .name { font-size: 26px; letter-spacing: 0.3em; padding-left: 0.3em; }
#connect .text { font-size: 15px; opacity: 0.75; }
#connect .detail { font-size: 12px; opacity: 0.5; max-width: 80vw; }

@keyframes pulse {
  0% { transform: scale(0.85); opacity: 0.9; }
  70% { transform: scale(1.15); opacity: 0.2; }
  100% { transform: scale(0.85); opacity: 0.9; }
}

@media (prefers-reduced-motion: reduce) {
  #connect.connecting .ring { animation: none; opacity: 0.9; }
  #stage, #connect { transition: none; }
}

#debug {
  position: fixed;
  top: 40px;
  left: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 260px;
}

#debug button {
  padding: 6px 10px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--bubble);
  color: var(--text);
  font-family: inherit;
}
