:root {
  --bg: #0d0d0f;
  --panel: #17171b;
  --line: #2c2c33;
  --text: #f4f1ea;
  --muted: #a39f97;
  --accent: #ffd60a;
  --accent-soft: rgba(255, 214, 10, .5);
  --red: #ff3b30;
  --ok: #34c759;
  --radius: 14px;
  --pad-top: max(20px, env(safe-area-inset-top));
  --pad-bottom: max(24px, env(safe-area-inset-bottom));
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 980px;
  margin: 0 auto;
  padding: var(--pad-top) 16px var(--pad-bottom);
}

.screen { display: flex; flex-direction: column; gap: 16px; }
#finish { max-width: 560px; margin: 7vh auto 0; }
#finish > .kicker, #finish > h1, #finish > .lede { text-align: center; text-wrap: balance; }

/* Setup screens (welcome, upright) and the booth fill the screen and end with the same
   .booth-bottom, so every action button sits where Record is, on phones and laptops.
   Setup content is centered in the space above it (the camera's space). */
.setup, #booth {
  min-height: calc(100vh - var(--pad-top) - var(--pad-bottom));
  min-height: calc(100dvh - var(--pad-top) - var(--pad-bottom));
}
.setup { max-width: 560px; margin: 0 auto; }
.setup-stage { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 16px; }
#welcome h1, #welcome .lede { text-align: center; }

.kicker {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
}

h1 {
  margin: 0;
  font-size: clamp(34px, 7vw, 56px);
  line-height: 1.02;
  font-weight: 850;
  letter-spacing: -.02em;
  text-wrap: balance;
}

.lede { margin: 0; font-size: 18px; color: var(--muted); }
.lede strong { font-weight: 700; color: var(--accent); }

form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
label { font-size: 14px; font-weight: 600; }
input {
  font: inherit;
  font-size: 18px;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}
input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
form .btn { margin-top: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  min-width: 150px;
  padding: 14px 24px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}
.btn.primary { background: var(--text); border-color: var(--text); color: var(--bg); }
.btn.record { background: var(--red); border-color: var(--red); color: #fff; }
.btn.record i { width: 14px; height: 14px; border-radius: 50%; background: #fff; }
.btn.small { min-height: 36px; min-width: 0; padding: 6px 14px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.tips { margin: 4px 0 0; padding-left: 20px; color: var(--muted); font-size: 15px; }

.notice {
  margin: 0;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #5c4b10;
  background: #2a2410;
  color: #ffe9a3;
}
.notice.error { border-color: #6b2121; background: #2e1212; color: #ffc9c4; }

/* Booth */
.prompt {
  margin: 0;
  font-size: clamp(28px, 3.8vw, 36px);
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -.01em;
}

.prompt em { font-style: italic; color: var(--accent); }

.booth-top, .booth-bottom { display: flex; flex-direction: column; gap: 10px; }
.booth-top { text-align: center; }
.booth-top .prompt { text-wrap: balance; }

.ideas ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.ideas li {
  padding: 3px 10px;
  border: 1px solid var(--accent-soft);
  border-radius: 999px;
  background: var(--panel);
  font-size: 13px;
  line-height: 1.4;
  color: var(--accent);
}

/* --ar is the camera's width / height and --frame-h the free height; app.js sets both. */
.frame {
  --ar: 1.7778;
  position: relative;
  width: min(100%, calc(56vh * var(--ar)));
  width: min(100%, calc(var(--frame-h, 56dvh) * var(--ar)));
  aspect-ratio: var(--ar);
  margin: auto; /* centered in any spare space between the question and the buttons */
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
}
.frame video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
#live { transform: scaleX(-1); }

.corners {
  position: absolute;
  inset: 14px;
  pointer-events: none;
  opacity: .75;
  --c: rgba(255, 255, 255, .9);
  background:
    linear-gradient(var(--c), var(--c)) top left / 24px 2px,
    linear-gradient(var(--c), var(--c)) top left / 2px 24px,
    linear-gradient(var(--c), var(--c)) top right / 24px 2px,
    linear-gradient(var(--c), var(--c)) top right / 2px 24px,
    linear-gradient(var(--c), var(--c)) bottom left / 24px 2px,
    linear-gradient(var(--c), var(--c)) bottom left / 2px 24px,
    linear-gradient(var(--c), var(--c)) bottom right / 24px 2px,
    linear-gradient(var(--c), var(--c)) bottom right / 2px 24px;
  background-repeat: no-repeat;
}

.hud {
  position: absolute;
  top: 24px;
  left: 26px;
  right: 26px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  font: 700 13px/1 ui-monospace, "SF Mono", Consolas, monospace;
  letter-spacing: .08em;
}
.rec, .limit {
  white-space: nowrap;
  padding: 7px 10px;
  border-radius: 6px;
  background: rgba(0, 0, 0, .55);
}
.rec { display: inline-flex; align-items: center; gap: 8px; }
.rec i { width: 10px; height: 10px; border-radius: 50%; background: var(--red); animation: blink 1s steps(2, start) infinite; }
.rec b { font-weight: 700; }
.limit:empty { display: none; }
.limit.warn { color: var(--accent); }
@keyframes blink { to { visibility: hidden; } }

.countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: min(28vw, 150px);
  font-weight: 900;
  text-shadow: 0 4px 30px rgba(0, 0, 0, .6);
  background: rgba(0, 0, 0, .25);
}

.chip {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .65);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.meter {
  position: absolute;
  left: 26px;
  bottom: 26px;
  width: 64px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, .2);
  overflow: hidden;
}
.meter i {
  display: block;
  height: 100%;
  background: var(--ok);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 60ms linear;
}

/* Between questions: "Answer N saved" over the camera, then the next question fades in. */
.saved {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  background: rgba(13, 13, 15, .85);
  text-align: center;
  animation: saved 1.6s ease forwards;
}
.saved svg { width: 56px; height: 56px; fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.saved b { font-size: 22px; }
.saved span { font-size: 15px; color: var(--muted); }
@keyframes saved {
  0% { opacity: 0; }
  12%, 78% { opacity: 1; }
  100% { opacity: 0; }
}
.booth-top.enter { animation: enter .5s ease .9s both; }
@keyframes enter {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  @keyframes enter { from { opacity: 0; } to { opacity: 1; } }
}

.controls { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.status-line { margin: 0; text-align: center; color: var(--muted); font-size: 14px; min-height: 1.45em; }
#booth-error { color: #ffc9c4; }

/* Phones held sideways: video on the left, words and buttons on the right. */
@media (orientation: landscape) and (max-height: 520px) {
  :root { --pad-top: max(12px, env(safe-area-inset-top)); --pad-bottom: 12px; }
  main { max-width: none; }
  #booth {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
    grid-template-rows: 1fr auto;
    column-gap: 16px;
    row-gap: 10px;
    height: calc(100dvh - var(--pad-top) - var(--pad-bottom));
  }
  #booth .frame { grid-column: 1; grid-row: 1 / -1; width: auto; height: 100%; max-width: 100%; align-self: center; }
  #booth .booth-top { grid-column: 2; grid-row: 1; overflow-y: auto; }
  #booth .booth-bottom { grid-column: 2; grid-row: 2; }
  #booth .prompt { font-size: 20px; }
  #upright .phone-icon { width: 40px; height: 64px; }
  #upright h1 { font-size: 30px; }
}

/* Upright reminder (phones and tablets only) */
#upright .setup-stage { align-items: center; text-align: center; }
.phone-icon { width: 64px; height: 104px; color: var(--accent); animation: tilt-up 2.4s ease-in-out infinite; }
@keyframes tilt-up {
  0%, 15% { transform: rotate(-90deg); }
  45%, 100% { transform: rotate(0deg); }
}
@media (prefers-reduced-motion: reduce) { .phone-icon { animation: none; } }
.orientation { margin: 0; font-weight: 700; color: var(--accent); }
.orientation.ok { color: var(--ok); }

/* Finish */
.uploads { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.uploads li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.uploads .label { font-weight: 700; }
.uploads .state { color: var(--muted); font-size: 14px; }
.uploads .state.sent { color: var(--ok); }
.uploads .state.failed { color: #ff8a80; }
.uploads .bar { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.uploads .bar i { display: block; height: 100%; background: var(--accent); transform-origin: left; transition: transform 200ms; }
.uploads .actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.uploads .actions a { color: var(--text); text-decoration: none; }
