:root {
  --bg: #1a1410;
  --bg-raise: #2a1d14;
  --ink: #f4e8d4;
  --muted: #c4b09a;
  --amber: #e8a54b;
  --amber-ink: #2a1a08;
  --sage: #7ea88a;
  --danger: #c45c26;
  --danger-ink: #fff4ec;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Nunito, ui-rounded, system-ui, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#app,
.screen {
  min-height: 100%;
  height: 100%;
}

.screen {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 28px;
  padding: 32px 24px 40px;
  max-width: 560px;
  margin: 0 auto;
}

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

.screen-tunnel {
  max-width: none;
  padding: 0;
  cursor: none;
  position: relative;
  background: #0c0907;
}

.brand {
  text-align: center;
}

.mark {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

h1 {
  font-family: Fraunces, ui-serif, Georgia, serif;
  font-weight: 650;
  font-size: clamp(3rem, 10vw, 4.5rem);
  letter-spacing: -0.04em;
  margin: 0;
}

h2 {
  font-family: Fraunces, ui-serif, Georgia, serif;
  margin: 0 0 8px;
  font-size: 1.8rem;
}

.lede,
.hint,
.waiting,
.overlay-sub,
.eyebrow {
  color: var(--muted);
  line-height: 1.45;
  text-align: center;
}

.lede {
  font-size: 1.15rem;
  margin: 8px 0 0;
}

.hint {
  font-size: 0.95rem;
  margin: 0;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.85rem;
  margin: 0;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 22px;
  min-height: 72px;
  padding: 16px 22px;
  font: inherit;
  font-weight: 800;
  font-size: 1.25rem;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--amber);
  color: var(--amber-ink);
}

.btn-secondary {
  background: var(--bg-raise);
  color: var(--ink);
  box-shadow: inset 0 0 0 2px #3d2a1c;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  min-height: 56px;
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  box-shadow: inset 0 0 0 2px var(--danger);
}

.btn-pill {
  min-height: 56px;
  border-radius: 999px;
  background: rgba(26, 20, 16, 0.72);
  color: var(--ink);
  backdrop-filter: blur(8px);
}

.code {
  font-family: Fraunces, ui-serif, Georgia, serif;
  font-size: clamp(2.8rem, 14vw, 4.4rem);
  letter-spacing: 0.16em;
  text-align: center;
  margin: 0;
  color: var(--amber);
}

.waiting {
  margin: 0;
}

#join-code {
  width: 100%;
  min-height: 84px;
  border: 0;
  border-radius: 22px;
  background: var(--bg-raise);
  color: var(--ink);
  font-family: Fraunces, ui-serif, Georgia, serif;
  font-size: 2rem;
  letter-spacing: 0.22em;
  text-align: center;
  text-transform: uppercase;
  box-shadow: inset 0 0 0 2px #3d2a1c;
}

#join-code:focus {
  outline: 3px solid var(--amber);
}

.error {
  color: #f0b090;
  text-align: center;
  margin: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

#remote,
#local {
  position: absolute;
  object-fit: cover;
  background: #0c0907;
  pointer-events: none;
}

#remote {
  inset: 0;
  width: 100%;
  height: 100%;
}

#local {
  width: min(28vw, 180px);
  height: min(36vw, 240px);
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  border-radius: 22px;
  box-shadow: var(--shadow);
  transform: scaleX(-1);
  z-index: 2;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 32px;
  background: rgba(14, 10, 8, 0.72);
  z-index: 10;
  text-align: center;
  pointer-events: auto;
  cursor: default;
}

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

.overlay-idle {
  background: rgba(26, 20, 16, 0.82);
}

.overlay-title {
  font-family: Fraunces, ui-serif, Georgia, serif;
  font-size: clamp(1.8rem, 6vw, 2.6rem);
  margin: 0;
}

.overlay-sub {
  max-width: 28rem;
  margin: 0;
}

.chrome {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(20px, env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  gap: 12px;
  z-index: 20;
  padding: 0 16px;
  pointer-events: auto;
  cursor: default;
}

dialog {
  border: 0;
  border-radius: 28px;
  padding: 28px 24px;
  background: #2a1d14;
  color: var(--ink);
  width: min(420px, calc(100vw - 32px));
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(8, 6, 5, 0.72);
}

dialog p {
  color: var(--muted);
  line-height: 1.45;
}

@media (max-width: 640px) {
  .screen:not(.screen-tunnel) {
    justify-content: flex-end;
    padding-bottom: 48px;
  }
}
