:root {
  --bg: #fafaf7;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #ea580c;
  --accent-ink: #ffffff;
  --good: #16a34a;
  --bad: #dc2626;
  --card: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(15 23 42 / 0.04), 0 4px 16px rgb(15 23 42 / 0.06);
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Inter Tight", "Inter", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --ink: #f8fafc;
    --muted: #94a3b8;
    --line: #1e293b;
    --card: #111827;
    --accent: #fb923c;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: 24px 20px max(24px, env(safe-area-inset-bottom));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Landscape on small phones can swallow the submit button under the keyboard.
   Tighten vertical rhythm so the Join button stays in view (Mark finding). */
@media (max-height: 480px) {
  #app {
    gap: 12px;
    padding-top: 12px;
  }
  h1 {
    font-size: 22px;
  }
  .field input,
  .field textarea {
    padding: 10px 12px;
  }
  .btn {
    padding: 12px 14px;
  }
}

.eyebrow {
  font-family: ui-monospace, "JetBrains Mono", monospace;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
  color: var(--muted);
}

h1,
h2 {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
  margin: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.15;
}

h2 {
  font-size: 22px;
  line-height: 1.2;
}

p {
  margin: 0;
  line-height: 1.5;
  color: var(--ink);
}

.muted {
  color: var(--muted);
  font-size: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.header .room {
  font-family: ui-monospace, "JetBrains Mono", monospace;
  font-size: 14px;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.header .you {
  font-size: 14px;
  color: var(--muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.field input,
.field textarea {
  font: inherit;
  font-size: 16px; /* iOS Safari auto-zooms on focus when input < 16px (Mark Fix 8) */
  width: 100%;
  padding: 14px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  outline: none;
  transition: border-color 120ms ease;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
}

.field textarea {
  resize: vertical;
  min-height: 120px;
}

.btn {
  font: inherit;
  font-weight: 600;
  padding: 16px 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  width: 100%;
  text-align: center;
  transition: transform 80ms ease, background 120ms ease;
}

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

.btn:disabled {
  background: var(--muted);
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  border-color: var(--line);
}

.options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option {
  font: inherit;
  text-align: left;
  padding: 18px 18px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-weight: 500;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, transform 80ms ease;
  display: flex;
  gap: 12px;
  align-items: center;
}

.option .marker {
  flex: 0 0 auto;
  font-family: ui-monospace, "JetBrains Mono", monospace;
  font-size: 12px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.option:hover {
  border-color: var(--accent);
}

.option:active {
  transform: scale(0.99);
}

.option.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--card));
}

.option.selected .marker {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.confirm {
  text-align: center;
  padding: 40px 20px;
}

.confirm .check {
  font-size: 56px;
  line-height: 1;
  color: var(--good);
  margin-bottom: 12px;
}

.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.error-banner {
  background: color-mix(in srgb, var(--bad) 10%, var(--card));
  border: 1px solid var(--bad);
  color: var(--bad);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
}

.spacer {
  flex: 1;
}

.byline {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@media (max-width: 420px) {
  h1 {
    font-size: 26px;
  }
}

.context strong {
  color: var(--ink);
  font-weight: 600;
}

.fw-reconnect-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 28px;
  z-index: 100;
  pointer-events: none; /* underneath state stays interactive once overlay clears */
}

.fw-reconnect-pill {
  pointer-events: auto;
  background: var(--card);
  color: var(--ink);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.fw-reconnect-pill::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bad);
  animation: fw-pulse 1.2s ease-in-out infinite;
}

@keyframes fw-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

option:disabled,
.option:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
