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

html,
body {
  margin: 0;
  height: 100%;
  background: #000;
  color: #f0f0f0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: fixed;
  inset: 0;
}

.view {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
}

.view.active {
  display: flex;
}

/* ─── password view ──────────────────────────────────────────────── */

#view-password form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

#password-input {
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 1.1rem;
  text-align: center;
  padding: 8px 12px;
  width: 240px;
  outline: none;
  letter-spacing: 0.08em;
  transition: border-color 200ms ease;
  caret-color: rgba(255, 255, 255, 0.6);
}

#password-input:focus {
  border-bottom-color: rgba(255, 255, 255, 0.7);
}

#password-input::placeholder {
  color: rgba(255, 255, 255, 0.25);
  letter-spacing: 0.08em;
}

.error {
  margin: 0;
  min-height: 1.2em;
  font-size: 0.85rem;
  color: rgba(255, 120, 120, 0.85);
  letter-spacing: 0.04em;
}

/* ─── connecting view ────────────────────────────────────────────── */

#view-connecting {
  background: #000;
}

#status-text {
  margin: 0;
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0.06em;
  animation: breathe 3.2s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.85; }
}

/* ─── portal view ────────────────────────────────────────────────── */

#view-portal {
  display: none;
  background: #000;
}

#view-portal.active {
  display: block;
}

#remote {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

#self {
  position: absolute;
  right: calc(18px + env(safe-area-inset-right, 0px));
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  width: 22vw;
  max-width: 200px;
  min-width: 120px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.55);
  background: #111;
  z-index: 3;
  transform: scaleX(-1); /* mirror self-view for natural framing */
  pointer-events: none;  /* taps pass through to the canvas */
}

#drawings {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  touch-action: none;
  cursor: crosshair;
  user-select: none;
  -webkit-user-select: none;
}

#pulse {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0) 60%);
}

#pulse.pulsing {
  animation: pulse 700ms ease-out;
}

@keyframes pulse {
  0% { opacity: 0; transform: scale(0.6); }
  35% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.6); }
}

/* Nudge shake — applied to the whole portal view */
#view-portal.shaking {
  animation: shake 520ms cubic-bezier(.36, .07, .19, .97);
}

@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-10px, 6px); }
  20% { transform: translate(9px, -5px); }
  30% { transform: translate(-7px, 7px); }
  40% { transform: translate(8px, -6px); }
  50% { transform: translate(-5px, 4px); }
  60% { transform: translate(5px, -3px); }
  70% { transform: translate(-3px, 2px); }
  80% { transform: translate(2px, -1px); }
  90% { transform: translate(-1px, 1px); }
}
