:root {
  --brown: #6b6141;
  --cream: #f3f1e7;
  --green: #8e9076;
  --ink: #2c2b27;
  --sand: #d8d2c6;
  --white: #ffffff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, "Suisse Intl", system-ui, sans-serif;
  color: var(--white);
  background: #1a1916;
  -webkit-text-size-adjust: 100%;
}

.page {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1.25rem, env(safe-area-inset-top))
           max(1.25rem, env(safe-area-inset-right))
           max(1.25rem, env(safe-area-inset-bottom))
           max(1.25rem, env(safe-area-inset-left));
}

.bg-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  z-index: 0;
  background: #1a1916 center/cover no-repeat;
  filter: none;
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.bg-shade {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  /* Minimal veil — max video clarity (Sara); soft bottom only for type */
  background: linear-gradient(
    180deg,
    rgba(44, 43, 39, 0.02) 0%,
    rgba(44, 43, 39, 0.06) 55%,
    rgba(44, 43, 39, 0.16) 100%
  );
}

.center {
  position: relative;
  z-index: 2;
  width: min(36rem, 100%);
  margin: auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.logo {
  /* Previous size — Sara: too big; she meant less space under logo */
  width: min(10.5rem, 46vw);
  height: auto;
  aspect-ratio: 220 / 310;
  display: block;
  margin: 0.35rem 0 -0.15rem;
  filter: drop-shadow(0 4px 22px rgba(0, 0, 0, 0.55)) drop-shadow(0 0 28px rgba(243, 241, 231, 0.18));
}

.copy-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.28rem;
  width: 100%;
  max-width: 28rem;
}

/* Sara 21 Nov: signup headings = Playfair (Instrument Serif is for the app only) */
.headline,
.support-line {
  font-family: "Playfair Display", Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: .01em;
  text-shadow: 0 2px 20px rgba(0,0,0,.42);
}

.headline {
  margin: 0;
  font-size: clamp(1.45rem, 3.1vw, 1.95rem);
  line-height: 1.22;
  max-width: 100%;
  white-space: nowrap;
  color: #f3f1e7;
}

.support-line {
  margin: 0;
  font-size: clamp(0.98rem, 1.9vw, 1.12rem);
  line-height: 1.3;
  color: rgba(243, 241, 231, 0.96);
}

.subline {
  margin: 0.15rem 0 0;
  max-width: 24rem;
  font-family: Inter, "Suisse Intl", system-ui, sans-serif;
  font-weight: 400;
  font-size: clamp(0.86rem, 1.55vw, 0.95rem);
  line-height: 1.45;
  letter-spacing: 0.01em;
  color: rgba(216, 210, 198, 0.92);
  text-shadow: 0 1px 12px rgba(0,0,0,.35);
}

.type-row {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  justify-content: center;
  margin-top: .75rem;
  width: 100%;
}

.type-btn {
  appearance: none;
  border: 1.5px solid rgba(243,241,231,.85);
  background: rgba(44,43,39,.28);
  color: var(--cream);
  border-radius: 999px;
  padding: .8rem 1.25rem;
  min-width: 11rem;
  font-size: .92rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .2s, border-color .2s, transform .15s;
  backdrop-filter: blur(6px);
  -webkit-tap-highlight-color: transparent;
}

.type-btn:hover {
  background: rgba(107,97,65,.55);
  border-color: var(--cream);
}

.type-btn.is-active {
  background: var(--cream);
  color: var(--ink);
  border-color: var(--cream);
}

.form-wrap {
  width: min(26rem, 100%);
  margin-top: 0.75rem;
  display: none;
}

.form-wrap.is-open { display: block; }

.pill {
  display: flex;
  align-items: stretch;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(243,241,231,.55);
  background: rgba(243,241,231,.12);
  backdrop-filter: blur(8px);
}

.pill input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--cream);
  padding: .9rem 1.1rem;
  font-size: 1rem;
  min-width: 0;
}

.pill input::placeholder { color: rgba(243,241,231,.55); }

.pill button {
  border: 0;
  background: var(--brown);
  color: var(--cream);
  padding: 0 1rem;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
}

.pill button:disabled {
  opacity: .65;
  cursor: wait;
}

.msg {
  margin-top: .75rem;
  min-height: 1.4em;
  font-size: .95rem;
  line-height: 1.45;
  font-weight: 500;
  color: var(--cream);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.msg.is-error { color: #ffc4c4; }
.msg.is-ok { color: #e4f5d4; }

.sound-btn {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 6;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 999px;
  border: 1px solid rgba(243,241,231,.55);
  background: rgba(44,43,39,.45);
  color: var(--cream);
  cursor: pointer;
  backdrop-filter: blur(6px);
  font-size: .85rem;
}

.sound-btn[aria-pressed="true"] {
  background: var(--brown);
}

.sound-btn.is-waiting {
  animation: soundPulse 1.2s ease-in-out infinite;
}

.sound-gate {
  position: fixed;
  right: max(4.2rem, calc(env(safe-area-inset-right) + 3.2rem));
  bottom: max(1.05rem, env(safe-area-inset-bottom));
  z-index: 6;
  border: 1px solid rgba(243, 241, 231, 0.55);
  background: rgba(107, 97, 65, 0.92);
  color: #f3f1e7;
  border-radius: 999px;
  padding: .55rem 1rem;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.sound-gate[hidden] {
  display: none !important;
}

@keyframes soundPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(243, 241, 231, 0.35); }
  50% { transform: scale(1.06); box-shadow: 0 0 0 10px rgba(243, 241, 231, 0); }
}

.result-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
  background: var(--ink);
  color: var(--cream);
  text-align: center;
}

.result-page a {
  color: var(--sand);
}

@media (max-width: 768px) {
  .page {
    min-height: 100vh;
    min-height: 100dvh;
    padding: max(0.85rem, env(safe-area-inset-top))
             max(0.85rem, env(safe-area-inset-right))
             max(4.5rem, env(safe-area-inset-bottom))
             max(0.85rem, env(safe-area-inset-left));
    align-items: center;
    justify-content: center;
  }

  .center {
    width: 100%;
    gap: 0;
    max-width: 22rem;
    margin: auto;
  }

  .logo {
    width: min(7.75rem, 40vw);
    margin: 0.25rem 0 -0.1rem;
  }

  .copy-stack {
    gap: 0.22rem;
    max-width: 18.5rem;
  }

  .headline {
    font-size: clamp(0.98rem, 4.55vw, 1.2rem);
    white-space: nowrap;
    max-width: none;
    letter-spacing: 0;
  }

  .support-line {
    font-size: 1rem;
  }

  .subline {
    font-size: 0.9rem;
    max-width: 18.5rem;
    line-height: 1.4;
  }

  .type-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
    margin-top: 0.65rem;
    width: 100%;
    max-width: 18.5rem; /* same as copy/text width — equal buttons */
  }

  .type-btn {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 0.65rem 1.15rem;
    font-size: 0.86rem;
    min-height: 2.45rem;
  }

  .form-wrap {
    width: 100%;
    margin-top: 0.7rem;
  }

  /* Form open: center inside visible area above keyboard (visualViewport) */
  body.is-signup-open {
    overflow: hidden;
    height: 100%;
  }

  body.is-signup-open .page {
    overflow: hidden;
    min-height: 100dvh;
    align-items: center;
    justify-content: center;
  }

  body.is-signup-open .center {
    position: fixed;
    left: 50%;
    top: calc(var(--vv-top, 0px) + (var(--vv-h, 100dvh) / 2));
    transform: translate(-50%, -50%);
    width: min(22rem, calc(100% - 1.7rem));
    margin: 0;
    max-height: calc(var(--vv-h, 100dvh) - 0.75rem);
    overflow: hidden;
    z-index: 5;
  }

  body.is-signup-open .logo {
    display: block;
    width: min(6rem, 32vw);
    margin: 0 0 -0.05rem;
  }

  body.is-signup-open .copy-stack {
    gap: 0.08rem;
  }

  body.is-signup-open .headline {
    font-size: clamp(0.9rem, 4.1vw, 1.06rem);
  }

  body.is-signup-open .support-line {
    font-size: 0.88rem;
  }

  body.is-signup-open .subline {
    font-size: 0.8rem;
  }

  body.is-signup-open .type-row {
    margin-top: 0.35rem;
    gap: 0.3rem;
  }

  body.is-signup-open .type-btn {
    min-height: 2.25rem;
    padding: 0.5rem 1rem;
    font-size: 0.82rem;
  }

  body.is-signup-open .form-wrap {
    margin-top: 0.45rem;
  }

  body.is-signup-open .pill input {
    padding: 0.75rem 1rem;
  }

  body.is-signup-open .pill button {
    padding: 0.75rem 1rem;
  }

  body.is-signup-open .msg {
    min-height: 1.1em;
    margin-top: 0.45rem;
    font-size: 0.8rem;
  }

  .pill {
    flex-direction: column;
    border-radius: 1rem;
  }

  .pill input {
    padding: 0.85rem 1rem;
    font-size: 16px;
    text-align: center;
  }

  .pill button {
    padding: 0.85rem 1rem;
    border-radius: 0 0 1rem 1rem;
    font-size: 0.84rem;
    letter-spacing: 0.08em;
  }

  .msg { font-size: 0.92rem; }

  .sound-btn {
    width: 2.4rem;
    height: 2.4rem;
  }

  .sound-gate {
    font-size: 0.75rem;
    padding: 0.45rem 0.85rem;
    right: max(3.7rem, calc(env(safe-area-inset-right) + 2.8rem));
  }
}

@media (max-width: 380px) {
  .headline { font-size: clamp(0.9rem, 4.4vw, 1.05rem); }
  .support-line { font-size: 0.94rem; }
  .subline { font-size: 0.84rem; }
  .logo { width: min(7.5rem, 40vw); }
}

@media (min-width: 769px) and (max-width: 900px) {
  .headline {
    white-space: normal;
    font-size: 1.55rem;
  }
}
