* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --teal: #0f766e;
  --teal-light: #14b8a6;
  --teal-bg: #f0fdfa;
  --bg: #ffffff;
  --card: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Map ── */
#map {
  position: fixed;
  inset: 0;
  z-index: 0;
}
.maplibregl-ctrl-bottom-left, .maplibregl-ctrl-bottom-right {
  bottom: 220px !important;
}

/* ── App overlay ── */
#app {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
}
#app > * { pointer-events: auto; }
#app > .home,
#app > .form-overlay,
#app > .loading,
#app > .arrived-overlay {
  flex: 1;
}

/* ── Home screen ── */
.home {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 24px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.home-logo {
  width: 64px;
  height: 64px;
  margin-bottom: 8px;
}

.home h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 4px;
}

.home p {
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 32px;
}

.home-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 380px;
}

.home-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}
.home-card:active, .home-card:hover {
  border-color: var(--teal);
  background: var(--teal-bg);
}
.home-card h2 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 4px;
}
.home-card span {
  font-size: 14px;
  color: var(--text-secondary);
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 380px;
  color: var(--text-secondary);
  font-size: 13px;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Forms ── */
.form-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 24px;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.form-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}

.form-card h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}

.form-card .subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
  background: #f8fafc;
}
.form-group input:focus {
  border-color: var(--teal);
  background: white;
}
.form-group input::placeholder {
  color: #94a3b8;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--teal);
  color: white;
}
.btn-primary:active { background: #0d6560; }

.btn-secondary {
  background: #f1f5f9;
  color: var(--text);
  margin-top: 8px;
}
.btn-secondary:active { background: #e2e8f0; }

.btn-success {
  background: #16a34a;
  color: white;
}
.btn-success:active { background: #15803d; }

.btn-danger {
  background: #ef4444;
  color: white;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Bottom sheet ── */
.bottom-sheet {
  background: var(--card);
  border-radius: 20px 20px 0 0;
  padding: 16px 20px calc(16px + var(--safe-bottom));
  box-shadow: 0 -4px 32px rgba(0,0,0,0.1);
  max-height: 50vh;
  overflow-y: auto;
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: #cbd5e1;
  border-radius: 2px;
  margin: 0 auto 16px;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.sheet-header h3 {
  font-size: 17px;
  font-weight: 700;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 600;
}
.status-waiting {
  background: #fef3c7;
  color: #92400e;
}
.status-active {
  background: #d1fae5;
  color: #065f46;
}
.status-arrived {
  background: #dbeafe;
  color: #1e40af;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.5s ease infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

.stats-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.stat-box {
  flex: 1;
  background: #f8fafc;
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}
.stat-box .value {
  font-size: 22px;
  font-weight: 700;
  color: var(--teal);
}
.stat-box .label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Share code display ── */
.code-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px;
  background: #f8fafc;
  border: 2px dashed var(--border);
  border-radius: 12px;
  margin-bottom: 16px;
}
.code-display .char {
  font-size: 28px;
  font-weight: 800;
  font-family: 'SF Mono', 'Fira Code', monospace;
  letter-spacing: 4px;
  color: var(--teal);
}

.share-hint {
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* ── Guest join banner ── */
.join-banner {
  text-align: center;
  padding: 20px;
}
.join-banner .host-name {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}
.join-banner .host-detail {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 20px;
}

/* ── Top bar ── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  pointer-events: auto;
}

.top-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px);
  padding: 8px 14px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  border: 1px solid var(--border);
}
.top-pill img {
  width: 20px;
  height: 20px;
}

/* ── Marker styles ── */
.marker-host, .marker-guest {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
  border: 3px solid white;
  cursor: pointer;
}
.marker-host {
  background: var(--teal);
  color: white;
}
.marker-guest {
  background: #3b82f6;
  color: white;
  animation: guest-pulse 2s ease infinite;
}
@keyframes guest-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(59,130,246,0.4); }
  50% { box-shadow: 0 0 0 12px rgba(59,130,246,0); }
}

.marker-label {
  position: absolute;
  top: -28px;
  white-space: nowrap;
  background: white;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  pointer-events: none;
}

/* ── Loading ── */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: rgba(255,255,255,0.95);
}
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ── */
.toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: white;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  animation: toast-in 0.3s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Arrived celebration ── */
.arrived-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: rgba(255,255,255,0.95);
  text-align: center;
  padding: 24px;
}
.arrived-overlay .check {
  width: 80px;
  height: 80px;
  background: #d1fae5;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  margin-bottom: 16px;
}
.arrived-overlay h2 {
  font-size: 24px;
  margin-bottom: 8px;
}
.arrived-overlay p {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* ── Embed mode ── */
body.embed-mode #app {
  pointer-events: auto;
}
body.embed-mode .top-bar {
  display: none;
}

.embed-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  z-index: 10;
}
.embed-bar.embed-arrived {
  background: #d1fae5;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  color: #065f46;
}
.embed-check {
  font-size: 20px;
}
.embed-stat {
  font-size: 14px;
  color: var(--text);
}
.embed-stat strong {
  color: var(--teal);
  font-size: 16px;
}
.embed-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #065f46;
  background: #d1fae5;
  padding: 4px 10px;
  border-radius: 100px;
}
