:root {
  --ink: #142018;
  --ink-soft: #4a5c52;
  --paper: #eef5f0;
  --sea: #0d6b52;
  --sea-deep: #0a4a39;
  --coral: #e23d2c;
  --coral-deep: #b5261a;
  --coral-glow: rgba(226, 61, 44, 0.4);
  --line: rgba(20, 32, 24, 0.12);
  --font-display: "Syne", "Arial Black", sans-serif;
  --font-body: "Sora", sans-serif;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100dvh;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  overflow-x: hidden;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(90% 70% at 85% 20%, #f3cbb8 0%, transparent 55%),
    radial-gradient(80% 60% at 10% 80%, #b8dfc8 0%, transparent 50%),
    linear-gradient(160deg, #f4faf6 0%, #e7f1ea 45%, #f6ebe4 100%);
}

.shell {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: clamp(1.5rem, 4vw, 3rem);
}

.stage {
  width: min(100%, 1180px);
  animation: rise-in 0.65s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.stage.is-in-room .home-only {
  display: none;
}

.stage:not(.is-in-room) .room-only {
  display: none;
}

/* —— Home —— */
.home {
  display: grid;
  gap: 1.5rem;
  align-items: center;
  justify-items: stretch;
}

.home-copy {
  display: grid;
  gap: 1rem;
  justify-items: start;
  max-width: 34rem;
}

.eyebrow {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--sea);
}

.brand {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.12em 0.22em;
  font-family: var(--font-display);
  font-size: clamp(3.8rem, 11vw, 6.2rem);
  font-weight: 800;
  letter-spacing: -0.055em;
  line-height: 0.86;
  text-transform: none;
}

.brand-filler {
  color: var(--ink);
}

.brand-buzz {
  color: var(--coral);
  font-style: italic;
  letter-spacing: -0.04em;
}

.lede {
  margin: 0;
  max-width: 32ch;
  font-size: clamp(1.05rem, 2.2vw, 1.2rem);
  line-height: 1.55;
  color: var(--ink-soft);
}

.lede em {
  font-family: inherit;
  font-style: normal;
  font-weight: 700;
  color: var(--ink);
}

.home-cta {
  --cta-radius: 14px;
  --cta-height: 3.1rem;
  display: grid;
  gap: 0.75rem;
  width: min(100%, 22rem);
  justify-self: start;
}

.btn-host {
  appearance: none;
  border: none;
  border-radius: var(--cta-radius);
  min-height: var(--cta-height);
  padding: 0 1.25rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: white;
  cursor: pointer;
  background: var(--sea);
  transition: background 0.15s ease;
}

.btn-host:hover {
  background: var(--sea-deep);
}

.btn-host:active {
  background: #083d2f;
}

.home-cta-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.65rem;
  margin: 0.15rem 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.home-cta-divider::before,
.home-cta-divider::after {
  content: "";
  height: 1px;
  background: var(--line);
}

.join-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: stretch;
  gap: 0;
  min-height: var(--cta-height);
  border-radius: var(--cta-radius);
  background: white;
  box-shadow: inset 0 0 0 1.5px var(--line);
  overflow: hidden;
}

.join-bar input {
  min-width: 0;
  border: none;
  padding: 0 1rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-align: center;
  text-transform: uppercase;
  color: var(--ink);
  background: transparent;
  outline: none;
}

.join-bar input::placeholder {
  letter-spacing: 0.22em;
  color: rgba(20, 32, 24, 0.32);
}

.join-bar input:focus {
  background: rgba(13, 107, 82, 0.04);
}

.btn-join {
  appearance: none;
  border: none;
  border-left: 1.5px solid var(--line);
  padding: 0 1.2rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: var(--sea-deep);
  cursor: pointer;
  background: rgba(13, 107, 82, 0.08);
  transition: background 0.15s ease, color 0.15s ease;
}

.btn-join:hover {
  background: rgba(13, 107, 82, 0.14);
  color: var(--sea);
}

.btn-join:active {
  background: rgba(13, 107, 82, 0.2);
}

.error {
  margin: 0;
  color: var(--coral-deep);
  font-size: 0.9rem;
}

.home-art {
  margin: 0;
  width: 100%;
  max-width: 36rem;
  justify-self: center;
  animation: scene-in 0.85s cubic-bezier(0.22, 1, 0.36, 1) 0.08s both;
}

.home-art img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 22px 40px rgba(20, 32, 24, 0.14));
}

@media (min-width: 900px) {
  .home {
    grid-template-columns: minmax(20rem, 0.9fr) minmax(28rem, 1.15fr);
    grid-template-areas:
      "copy art"
      "cta art";
    column-gap: clamp(2rem, 5vw, 5rem);
    row-gap: 1.25rem;
    min-height: min(78vh, 720px);
    align-items: center;
  }

  .home-copy {
    grid-area: copy;
    align-content: end;
  }

  .home-cta {
    grid-area: cta;
    align-self: start;
    margin-top: 0;
  }

  .home-art {
    grid-area: art;
    max-width: none;
    justify-self: stretch;
    align-self: center;
    margin: 0;
  }
}

/* —— Room —— */
.room {
  display: none;
  width: min(100%, 28rem);
  margin: 0 auto;
  text-align: center;
  gap: 1.5rem;
}

.stage.is-in-room .room {
  display: grid;
  animation: rise-in 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.room-main {
  display: grid;
  justify-items: center;
  gap: 1rem;
}

.room-side {
  display: grid;
  justify-items: center;
  gap: 0.85rem;
  width: 100%;
  padding: 1.35rem 1.25rem;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: inset 0 0 0 1px var(--line);
}

.room-brand {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: 0.12em 0.2em;
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 4vw, 2.3rem);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1;
}

.hint {
  margin: 0;
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.hint[hidden] {
  display: none !important;
}

.room-code {
  display: grid;
  gap: 0.2rem;
  margin: 0;
}

.room-code-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.room-code-value {
  appearance: none;
  border: none;
  padding: 0.1rem 0.35rem;
  font-family: var(--font-display);
  font-size: clamp(2.3rem, 8vw, 3rem);
  font-weight: 800;
  letter-spacing: 0.18em;
  line-height: 1;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}

.room-code-value:hover {
  color: var(--sea);
}

.btn-invite {
  appearance: none;
  border: none;
  border-radius: 14px;
  min-height: 3.1rem;
  padding: 0 1.35rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: white;
  cursor: pointer;
  background: var(--sea);
  transition: background 0.15s ease;
}

.btn-invite:hover {
  background: var(--sea-deep);
}

.btn-invite:active {
  background: #083d2f;
}

.presence {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.leave-link {
  appearance: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.85rem;
  color: var(--ink-soft);
  background: none;
  cursor: pointer;
  opacity: 0.75;
}

.leave-link:hover {
  opacity: 1;
  color: var(--ink);
}

@media (min-width: 900px) {
  .stage.is-in-room .room {
    width: 100%;
    max-width: none;
    grid-template-columns: minmax(22rem, 1.15fr) minmax(16rem, 0.75fr);
    align-items: center;
    column-gap: clamp(2.5rem, 6vw, 5rem);
    text-align: left;
    min-height: min(78vh, 720px);
  }

  .room-main {
    justify-items: center;
    gap: 1.15rem;
  }

  .stage.is-in-room .buzzer {
    width: min(48vw, 360px);
  }

  .room-side {
    justify-items: start;
    align-content: center;
    gap: 1rem;
    padding: 1.75rem 1.5rem;
  }

  .room-brand {
    justify-content: center;
    font-size: clamp(2rem, 3.5vw, 2.8rem);
  }

  .room-code {
    justify-items: start;
  }

  .room-code-value {
    font-size: clamp(2.8rem, 5vw, 3.6rem);
    padding-left: 0;
  }

  .btn-invite {
    width: 100%;
  }
}

/* —— Buzzer —— */
.buzzer {
  --press: 0;
  position: relative;
  width: min(72vw, 280px);
  aspect-ratio: 1;
  border: none;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  background: transparent;
  isolation: isolate;
  transform: scale(calc(1 - var(--press) * 0.07));
  transition: transform 0.12s cubic-bezier(0.2, 0.8, 0.2, 1);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.buzzer-face {
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 28%, #ff7a6b 0%, transparent 42%),
    linear-gradient(180deg, #f04a38 0%, var(--coral-deep) 72%, #8f1b12 100%);
  box-shadow:
    inset 0 10px 18px rgba(255, 255, 255, 0.22),
    inset 0 -14px 24px rgba(0, 0, 0, 0.28),
    0 18px 0 var(--coral-deep),
    0 28px 40px var(--coral-glow);
  transition:
    box-shadow 0.12s ease,
    transform 0.12s ease;
  transform: translateY(calc(var(--press) * 10px));
}

.buzzer:active,
.buzzer.is-pressed {
  --press: 1;
}

.buzzer.is-pressed .buzzer-face,
.buzzer:active .buzzer-face {
  box-shadow:
    inset 0 10px 18px rgba(255, 255, 255, 0.18),
    inset 0 -10px 20px rgba(0, 0, 0, 0.32),
    0 8px 0 #8f1b12,
    0 14px 28px var(--coral-glow);
}

.buzzer-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(226, 61, 44, 0.45);
  opacity: 0;
  transform: scale(0.92);
  pointer-events: none;
}

.buzzer.is-buzzing .buzzer-ring {
  animation: ring-out 0.7s ease-out forwards;
}

.buzzer.is-buzzing .buzzer-ring.delay {
  animation-delay: 0.12s;
}

.buzzer.is-buzzing .buzzer-face {
  animation: face-flash 0.55s ease;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  z-index: 5;
  transform: translateX(-50%) translateY(120%);
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  background: rgba(20, 32, 24, 0.92);
  color: white;
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0;
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scene-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes ring-out {
  0% {
    opacity: 0.7;
    transform: scale(0.95);
  }
  100% {
    opacity: 0;
    transform: scale(1.35);
  }
}

@keyframes face-flash {
  0%,
  100% {
    filter: brightness(1);
  }
  35% {
    filter: brightness(1.18);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
