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

body {
  background: #0d0d1a;
  overflow: hidden;
  font-family: system-ui, sans-serif;
  color: #fff;
}

#canvas {
  display: block;
  width: 100vw;
  height: 100vh;
}

/* ---------------------------------------------------------------------------
   Landing page
--------------------------------------------------------------------------- */
#landing {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d0d1a;
}

#landing-card {
  background: #1a1a2e;
  border: 1px solid #333;
  border-radius: 16px;
  padding: 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-width: 320px;
  text-align: center;
}

#landing-card h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #a89cf7;
}

#landing-card p {
  color: #888;
  font-size: 0.95rem;
}

#landing-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#landing-error {
  display: none;
  color: #f76a6a;
  font-size: 0.85rem;
}

/* ---------------------------------------------------------------------------
   HUD bar — bottom center
--------------------------------------------------------------------------- */
#hud {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(13, 13, 26, 0.75);
  backdrop-filter: blur(10px);
  border: 1px solid #333;
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  box-shadow: 0 2px 16px rgba(0,0,0,0.4);
  pointer-events: auto;
}

/* Divider after hamburger separates it from A/V controls */
#hud-more {
  border-right: 1px solid rgba(255,255,255,0.15);
  padding-right: 0.6rem;
  margin-right: 0.1rem;
}

.hud-btn {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.3rem 0.4rem;
  border-radius: 50%;
  line-height: 1;
  transition: background 0.15s, opacity 0.15s;
  color: #fff;
  width: 2.2rem;
  height: 2.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hud-btn:hover { background: rgba(255,255,255,0.1); }
.hud-btn.muted, .hud-btn.paused { opacity: 0.4; }
.hud-btn.active { background: rgba(255,255,255,0.25); }

#hud-name-wrap {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.25rem;
}

#hud-name-input {
  width: 130px;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  border: 1px solid #444;
  background: rgba(255,255,255,0.07);
  color: #fff;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.15s, width 0.2s;
}
#hud-name-input:focus { border-color: #7c6af7; width: 160px; }
#hud-name-input::placeholder { color: #666; }

.hud-name-btn {
  font-size: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
#hud-name-input:focus ~ .hud-name-btn,
.hud-name-btn:focus {
  opacity: 1;
  pointer-events: auto;
}
/* show confirm button when input has content */
#hud-name-input.has-value ~ .hud-name-btn {
  opacity: 1;
  pointer-events: auto;
}

#conn-status {
  position: fixed;
  bottom: 12px;
  left: 12px;
  font: 12px/1 monospace;
  color: #ccc;
  pointer-events: none;
  z-index: 999;
}
#conn-status[data-state="failed"]         { color: #f66; }
#conn-status[data-state="camera_blocked"] { color: #fa0; }
#conn-status[data-state="reconnecting"]   { color: #fa0; }
#conn-status[data-state="ok"]             { color: #4c4; }

/* ---------------------------------------------------------------------------
   Shared input / button styles
--------------------------------------------------------------------------- */
input[type="text"] {
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
  border: 1px solid #555;
  background: #0d0d1a;
  color: #fff;
  font-size: 1rem;
  outline: none;
  width: 100%;
}
input[type="text"]:focus { border-color: #7c6af7; }

button {
  padding: 0.55rem 1.25rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: opacity 0.15s;
}
button:hover:not(:disabled) { opacity: 0.85; }
button:disabled { opacity: 0.5; cursor: default; }

#create-btn { background: #7c6af7; color: #fff; width: 100%; }

/* ---------------------------------------------------------------------------
   More settings panel
--------------------------------------------------------------------------- */
#more-panel {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 11;
  background: rgba(13, 13, 26, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid #333;
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  display: none;
  flex-direction: column;
  gap: 0.6rem;
  min-width: 220px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
  /* sit just below the HUD pill — JS sets margin-top after measuring */
}

#more-panel.open {
  display: flex;
  border-left: 2px solid rgba(124, 106, 247, 0.5);
}

.more-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.82rem;
  color: #ccc;
}

.more-row label {
  white-space: nowrap;
  flex-shrink: 0;
}

.more-row input[type="range"] {
  flex: 1;
  accent-color: #7c6af7;
  cursor: pointer;
}

#cam-height-val {
  font-size: 0.75rem;
  color: #888;
  width: 2.5rem;
  text-align: right;
  flex-shrink: 0;
}

.more-row-btns {
  justify-content: flex-start;
  padding-top: 0.1rem;
}

.periscope-btn {
  width: 100%;
  text-align: center;
  font-variant: small-caps;
  letter-spacing: 0.08em;
  transition: background 0.15s, color 0.15s;
}
.periscope-btn.active {
  background: rgba(124,106,247,0.3);
  border-color: rgba(124,106,247,0.6);
  color: #c4b8ff;
}

.more-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: #ccc;
  border-radius: 6px;
  padding: 0.3rem 0.75rem;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s;
}
.more-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }

/* ---------------------------------------------------------------------------
   Help card — bottom-left corner, non-blocking
--------------------------------------------------------------------------- */
.help-overlay {
  position: fixed;
  top: 4rem;         /* just below HUD pill */
  left: 1rem;
  z-index: 30;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.25s ease, visibility 0.25s ease, transform 0.25s ease;
}
.help-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}
.help-overlay.slow-fade {
  transition: opacity 0.6s ease, visibility 0.6s ease, transform 0.6s ease;
}

.help-box {
  background: rgba(13,13,26,0.95);
  border: 1px solid #444;
  border-radius: 0.85rem;
  padding: 1.1rem 1.4rem 1rem;
  max-width: 300px;
  color: #fff;
  font-family: system-ui, sans-serif;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}

.help-box h2 {
  margin: 0 0 0.85rem;
  font-size: 0.95rem;
  color: #c4b8ff;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.help-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.4rem 0.85rem;
  margin-bottom: 0.85rem;
  align-items: center;
}

.help-keys {
  display: flex;
  gap: 0.2rem;
  flex-wrap: wrap;
}

kbd {
  background: rgba(255,255,255,0.1);
  border: 1px solid #555;
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  font-size: 0.73rem;
  font-family: monospace;
  color: #ddd;
  white-space: nowrap;
}

.help-desc {
  font-size: 0.78rem;
  color: #aaa;
}

.help-tip {
  font-size: 0.76rem;
  color: #888;
  margin: 0 0 0.5rem;
  line-height: 1.5;
}

.help-dismiss-hint {
  font-size: 0.7rem;
  color: #555;
  text-align: center;
  margin: 0;
  font-style: italic;
}

.help-close {
  display: block;
  margin: 0;
  padding: 0.3rem 0.9rem;
  font-size: 0.78rem;
}

/* ---------------------------------------------------------------------------
   Name sticker — bottom-right corner, "Hello my name is" badge
--------------------------------------------------------------------------- */
#name-sticker {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 30;
  width: 220px;
  background: #fff;
  border-radius: 6px 6px 8px 8px;
  box-shadow: 0 6px 28px rgba(0,0,0,0.55), 0 1px 4px rgba(0,0,0,0.3);
  font-family: system-ui, sans-serif;
  overflow: hidden;
  transform: rotate(1.5deg);
  transform-origin: bottom right;
  transition: opacity 0.4s ease, transform 0.4s ease;
  opacity: 1;
}
#name-sticker.sticker-exit {
  opacity: 0;
  transform: rotate(4deg) translateY(12px);
}

.sticker-header {
  background: #e8192c;
  color: #fff;
  text-align: center;
  padding: 0.5rem 0.75rem 0.35rem;
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1.1;
  text-transform: uppercase;
}
.sticker-header span {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  opacity: 0.92;
  margin-top: 0.1rem;
}

.sticker-body {
  padding: 0.6rem 0.75rem 0.3rem;
  display: flex;
  gap: 0.4rem;
  align-items: center;
  border-bottom: 1px solid #f0f0f0;
}

.sticker-body input {
  flex: 1;
  border: none;
  border-bottom: 2px solid #ccc;
  background: transparent;
  font-size: 1.1rem;
  font-family: 'Patrick Hand', 'Comic Sans MS', cursive, system-ui;
  color: #111;
  outline: none;
  padding: 0.1rem 0.2rem;
  min-width: 0;
}
.sticker-body input:focus { border-bottom-color: #e8192c; }
.sticker-body input::placeholder { color: #bbb; font-style: italic; }

.sticker-body button {
  background: #e8192c;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 1.8rem;
  height: 1.8rem;
  font-size: 0.9rem;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s;
}
.sticker-body button:hover { background: #c0111f; }

.sticker-hint {
  text-align: center;
  font-size: 0.65rem;
  color: #aaa;
  padding: 0.25rem 0.5rem 0.4rem;
}
