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

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0a0a;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: #f2f2f2;
}

#video {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

#canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  object-fit: cover;
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(8, 8, 10, 0.72);
  transition: opacity 0.35s ease, visibility 0.35s ease;
  z-index: 2;
  overflow-y: auto;
}

.overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.start-panel {
  width: min(34rem, 100%);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1rem;
}

.start-panel h1 {
  margin: 0;
  font-size: clamp(1.75rem, 4vw, 2.35rem);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.lede {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.45;
  color: rgba(245, 245, 245, 0.88);
}

.directions {
  margin: 0;
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  font-size: 0.95rem;
  line-height: 1.4;
  color: rgba(235, 235, 235, 0.9);
}

.directions strong {
  font-weight: 600;
  color: #fff;
}

#startBtn,
#stopBtn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(20, 20, 24, 0.85);
  color: #f5f5f5;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  padding: 0.85rem 1.5rem;
  cursor: pointer;
  border-radius: 2px;
  align-self: center;
}

#startBtn:hover,
#stopBtn:hover {
  background: rgba(36, 36, 42, 0.95);
}

#startBtn:disabled {
  opacity: 0.55;
  cursor: wait;
}

#stopBtn {
  font-size: 0.9rem;
  padding: 0.45rem 0.9rem;
  align-self: auto;
}

.status {
  margin: 0;
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.4;
  color: rgba(245, 245, 245, 0.85);
  min-height: 1.4em;
}

.status.error {
  color: #ff8f8f;
}

.hud {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  padding: 0.85rem 1.1rem;
  background: linear-gradient(to top, rgba(6, 6, 8, 0.82), rgba(6, 6, 8, 0.35));
  pointer-events: none;
}

.hud.hidden {
  display: none;
}

.hud-tip {
  margin: 0;
  flex: 1 1 16rem;
  font-size: 0.85rem;
  line-height: 1.35;
  color: rgba(240, 240, 240, 0.88);
  max-width: 36rem;
}

.hud-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  pointer-events: auto;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: rgba(245, 245, 245, 0.92);
  cursor: pointer;
  user-select: none;
}

.toggle input {
  width: 1rem;
  height: 1rem;
  accent-color: #c8c8c8;
  cursor: pointer;
}

@media (max-width: 560px) {
  .hud {
    flex-direction: column;
    align-items: flex-start;
  }

  .hud-controls {
    width: 100%;
  }
}
