:root {
  --parakeet: #00ff7f;
  --parakeet-dim: #0f8a4c;
  --red: #e2231e;
  --red-dim: #a01a16;
  --white: #ffffff;
  --black: #000000;
  --panel: #0a0d0a;
}

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

html, body {
  background: var(--black);
  color: var(--white);
}

body {
  font-family: Arial, Helvetica, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
}

.stage {
  width: 100%;
  max-width: 640px;
  padding: env(safe-area-inset-top, 14px) 14px calc(env(safe-area-inset-bottom, 14px) + 8px);
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

/* ---------- Header ---------- */
.stage__header {
  display: grid;
  gap: 8px;
  text-align: center;
  padding-top: 6px;
}

h1 {
  color: var(--parakeet);
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 700;
  font-size: clamp(1.4rem, 7.2vw, 2.1rem);
  line-height: 1.15;
  letter-spacing: 0.5px;
  text-shadow: 0 0 14px rgba(0, 255, 127, 0.35);
}

/* ---------- Booth / camera preview ---------- */
.booth {
  display: flex;
  justify-content: center;
}

.booth__frame {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4; /* fallback shape before JS sizes it exactly */
  max-height: 64dvh;
  background: var(--panel);
  border-radius: 12px;
  overflow: hidden;
  border: 9px solid var(--parakeet);
}

#preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  opacity: 0; /* the canvas is the visible composite once ready */
}

#stageCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
}

.permission-gate {
  position: absolute;
  inset: 0;
  z-index: 6;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  padding: 20px;
}

.permission-gate p {
  color: var(--parakeet);
  font-family: Arial, Helvetica, sans-serif;
  text-transform: uppercase;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.5;
}

.hidden { display: none !important; }

.ghost-btn {
  background: transparent;
  border: 2px solid var(--parakeet);
  color: var(--parakeet);
  font-family: Arial, Helvetica, sans-serif;
  text-transform: uppercase;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 14px 28px;
  border-radius: 10px;
  cursor: pointer;
}

.ghost-btn:active { background: rgba(0, 255, 127, 0.12); }

.countdown {
  position: absolute;
  top: 67%; /* directly below the title/end card, which now sits just above this line */
  left: 0;
  right: 0;
  bottom: 2%;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(2.5rem, 16vh, 6rem);
  font-weight: 900;
  color: var(--white);
  pointer-events: none;
  font-family: Arial, Helvetica, sans-serif;
}

/* ---------- Controls ---------- */
.controls {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding-top: 2px;
}

.rec-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  -webkit-tap-highlight-color: transparent;
}

.rec-btn:disabled { opacity: 0.35; pointer-events: none; }

.rec-btn__ring {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: var(--red);
  outline: 2px solid var(--red);
  outline-offset: 6px;
  box-shadow: 0 4px 26px rgba(226, 35, 30, 0.4);
  transition: box-shadow 0.2s ease;
}

.rec-btn__label {
  color: var(--black);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 1px;
  font-family: Arial, Helvetica, sans-serif;
}

.rec-btn.is-active .rec-btn__ring {
  animation: pulse-ring 1.1s ease-in-out infinite;
}

@keyframes pulse-ring {
  0%, 100% { box-shadow: 0 0 0 0 rgba(226, 35, 30, 0.55); }
  50% { box-shadow: 0 0 0 14px rgba(226, 35, 30, 0); }
}

.tagline {
  text-align: center;
  font-family: Arial, Helvetica, sans-serif;
  text-transform: uppercase;
  font-size: 1rem;
  font-weight: 700;
  color: var(--parakeet);
}

.helper {
  text-align: center;
  font-family: Arial, Helvetica, sans-serif;
  text-transform: uppercase;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--parakeet);
  max-width: 420px;
  min-height: 1.3em;
}

.bt-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: Arial, Helvetica, sans-serif;
  text-transform: uppercase;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--parakeet);
  cursor: pointer;
}

.bt-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--parakeet);
}

/* ---------- Disclaimer / footer ---------- */
.disclaimer {
  font-family: "Courier New", Courier, monospace;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--white);
  display: grid;
  gap: 10px;
  border-top: 1px solid rgba(0, 255, 127, 0.18);
  padding-top: 12px;
}

.disclaimer a.quiet-link { color: var(--white); }

/* ---------- Advanced settings ---------- */
.advanced-settings {
  font-family: "Courier New", Courier, monospace;
  color: var(--white);
  border: 1px solid rgba(0, 255, 127, 0.18);
  border-radius: 6px;
  padding: 10px 14px;
}

.advanced-settings summary {
  cursor: pointer;
  color: var(--parakeet);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 0.85rem;
}

.advanced-settings[open] summary {
  margin-bottom: 10px;
}

.advanced-settings .bt-toggle {
  padding-top: 8px;
}


/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal__panel {
  background: var(--panel);
  border: 2px solid var(--parakeet);
  border-radius: 16px;
  padding: 24px 20px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  display: grid;
  gap: 14px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal__title {
  color: var(--parakeet);
  font-family: Arial, Helvetica, sans-serif;
  text-transform: uppercase;
  font-size: 1.2rem;
  font-weight: 700;
  min-height: 1.4em;
}

.modal__spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto;
  border-radius: 50%;
  border: 4px solid rgba(0, 255, 127, 0.2);
  border-top-color: var(--parakeet);
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.modal__video {
  /* width:100% + a separate max-height forced a box wider than a portrait
     video's own aspect ratio, letterboxing it with black bars down the
     sides. Letting both dimensions size from the content avoids that. */
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 55vh;
  border-radius: 10px;
  background: #000;
}

.modal__share-tip {
  font-size: 1.15rem;
  line-height: 1.3;
  font-weight: 700;
  color: var(--parakeet);
}

.modal__actions {
  display: grid;
  gap: 10px;
}

.primary-btn {
  background: var(--parakeet);
  color: var(--black);
  font-family: Arial, Helvetica, sans-serif;
  text-transform: uppercase;
  font-weight: 700;
  font-size: 1.05rem;
  border: 2px solid var(--parakeet);
  border-radius: 10px;
  padding: 14px 28px;
  cursor: pointer;
}

.primary-btn:active { background: var(--parakeet-dim); }

/* ---------- Landscape adjustments ---------- */
@media (orientation: landscape) {
  .stage { max-width: 920px; }
  .booth__frame { max-height: 58dvh; }
}

@media (min-width: 700px) {
  .stage { max-width: 680px; padding-top: 26px; }
}
