// Split Crew — remaining app screens (join, dashboard, add expense, currency, settle)

// ═══════════════════════════════════════════════════════════════
// JOIN
// ═══════════════════════════════════════════════════════════════

// Trip lookup. Uses Supabase when configured; falls back to a small demo set offline.
function mockLookupTrip(code) {
  const c = code.replace(/-/g, '').toUpperCase();
  // Try Supabase first
  if (window.tt && window.tt.isOnline()) {
    return window.tt.lookupCrew(c).then((r) => {
      if (r.ok) {
        return {
          ok: true,
          trip: {
            id: r.crew.id,                    // Real UUID — used as crewId
            localId: 't_' + r.crew.code,      // Local key for expensesByTrip
            code: r.crew.code,
            name: r.crew.name,
            members: (r.crew.members || []).map(m => m.name).filter(Boolean),
            createdBy: (r.crew.members && r.crew.members[0] && r.crew.members[0].name) || '—',
          },
        };
      }
      return { ok: false, reason: r.reason || 'not-found' };
    }).catch(() => ({ ok: false, reason: 'error' }));
  }
  // Offline demo fallback
  return new Promise((resolve) => {
    setTimeout(() => {
      if (c === '000000') return resolve({ ok: false, reason: 'not-found' });
      if (c === '999999') return resolve({ ok: false, reason: 'closed' });
      resolve({
        ok: true,
        trip: {
          id: 't_' + c, localId: 't_' + c, code: c,
          name: c === '8A4F2K' ? 'Italy · w.17' : 'Crew Trip',
          members: ['Elin','Max','Nils'], createdBy: 'Elin',
        },
      });
    }, 700);
  });
}

function formatJoinCode(raw) {
  const cleaned = raw.toUpperCase().replace(/[^A-Z0-9]/g, '').slice(0, 6);
  return cleaned.length > 3 ? cleaned.slice(0, 3) + '-' + cleaned.slice(3) : cleaned;
}

function JoinScreen({ ctx }) {
  const [me, setMe] = useMe();
  const [code, setCode] = React.useState('');
  const [phase, setPhase] = React.useState('idle'); // idle | looking-up | found | error
  const [error, setError] = React.useState(null);
  const [tripPreview, setTripPreview] = React.useState(null);
  const [displayName, setDisplayName] = React.useState(me.name && me.name !== 'You' && me.name !== 'Du' ? me.name : '');
  const [joining, setJoining] = React.useState(false);

  const cleanCode = code.replace(/-/g, '');
  const isComplete = cleanCode.length === 6;

  // Auto-trigger lookup once 6 chars are entered
  React.useEffect(() => {
    if (!isComplete) {
      setPhase('idle');
      setTripPreview(null);
      setError(null);
      return;
    }
    let cancelled = false;
    setPhase('looking-up');
    setError(null);
    mockLookupTrip(cleanCode).then((res) => {
      if (cancelled) return;
      if (!res.ok) {
        setPhase('error');
        setError(
          res.reason === 'not-found' ? 'No trip with that code. Check with your friend.' :
          res.reason === 'closed' ? 'That trip is settled and closed.' :
          'Something went wrong. Try again.'
        );
        setTripPreview(null);
      } else {
        // Cap: max 10 members per trip.
        const max = (typeof window !== 'undefined' && window.MAX_TRIP_MEMBERS) || 10;
        const memberCount = (res.trip && res.trip.members) ? res.trip.members.length : 0;
        if (memberCount >= max) {
          setPhase('error');
          setError(`This trip is full (${memberCount} / ${max} crew). Ask the creator to remove someone before you join.`);
          setTripPreview(null);
          return;
        }
        setPhase('found');
        setTripPreview(res.trip);
      }
    });
    return () => { cancelled = true; };
  }, [cleanCode, isComplete]);

  const canJoin = phase === 'found' && displayName.trim().length >= 2 && !joining;

  const doJoin = () => {
    if (!canJoin) return;
    setJoining(true);
    // Persist display name globally
    const cleanName = displayName.trim();
    setMe({ ...me, name: cleanName });
    // Hand off to dashboard with the joined trip in pot.
    // members is seeded with just me; refreshMembers() will pull the authoritative list once crewId is set.
    const looksLikeUuid = /^[0-9a-f]{8}-/i.test(tripPreview.id || '');
    const joinedPot = {
      name: tripPreview.name,
      members: [cleanName],
      code: tripPreview.code,
      id: tripPreview.localId || tripPreview.id,
      crewId: looksLikeUuid ? tripPreview.id : undefined,
    };
    ctx.setPot(joinedPot);
    // Register this device's identity on the crew (idempotent on device_id).
    if (looksLikeUuid && window.tt && window.tt.isOnline()) {
      const did = (typeof getDeviceId === 'function') ? getDeviceId() : null;
      window.tt.addMember({ crewId: tripPreview.id, name: cleanName, deviceId: did }).catch(() => {});
    }
    // Persist the joined trip to recent-trips list directly, with the explicit pot.
    // (Don't rely on commitTrip's closure — it captures the previous pot, which is empty.)
    if (ctx.commitTrip) ctx.commitTrip(joinedPot);
    ctx.go('dashboard');
  };

  return (
    <div>
      <AppHeader back={() => ctx.go('home')} title="JOIN A TRIP" />
      <div style={{ padding: '8px 24px 32px' }}>
        <h1 className="display" style={{ fontSize: 28, lineHeight: 1.05, marginBottom: 8 }}>Enter the code</h1>
        <p style={{ fontSize: 12, color: 'var(--text-mu)', lineHeight: 1.5, marginBottom: 18 }}>
          Ask a crew member for the 6-character code, or scan their QR.
        </p>

        {/* Code input */}
        <div style={{
          border: '1px solid ' + (
            phase === 'error' ? '#E86B3B' :
            phase === 'found' ? '#7DE08B' :
            'var(--cyan-500)'
          ),
          padding: '14px 16px',
          background: 'rgba(10,20,32,0.4)',
          marginBottom: 14,
        }}>
          <div style={{ fontSize: 10, letterSpacing: '0.24em', color: 'var(--text-mu)', fontFamily: 'var(--font-display)', marginBottom: 4 }}>TRIP CODE</div>
          <input
            value={code}
            onChange={e => setCode(formatJoinCode(e.target.value))}
            placeholder="XXX-XXX"
            autoFocus
            inputMode="text"
            autoCapitalize="characters"
            autoCorrect="off"
            spellCheck="false"
            style={{
              background: 'transparent', border: 'none', outline: 'none',
              fontFamily: 'var(--font-display)', fontWeight: 700, fontSize: 28, letterSpacing: '0.18em',
              color: 'var(--text-hi)', width: '100%', padding: 0, marginTop: 2,
              textTransform: 'uppercase',
            }}
          />
        </div>

        {/* Status messages */}
        {phase === 'looking-up' && (
          <div style={{
            display: 'flex', alignItems: 'center', gap: 10,
            padding: '10px 14px', border: '1px dashed var(--cyan-500)',
            background: 'rgba(59,180,232,0.04)', marginBottom: 14,
          }}>
            <span style={{
              width: 8, height: 8, borderRadius: '50%',
              background: 'var(--cyan-500)', boxShadow: '0 0 6px var(--cyan-500)',
              animation: 'pulse 1s ease-in-out infinite',
            }} />
            <span style={{ fontSize: 11, color: 'var(--cyan-100)', fontFamily: 'var(--font-display)', letterSpacing: '0.18em' }}>
              LOOKING UP TRIP…
            </span>
          </div>
        )}

        {phase === 'error' && error && (
          <div style={{
            padding: '12px 14px', border: '1px solid rgba(232,107,59,0.5)',
            background: 'rgba(232,107,59,0.06)', marginBottom: 14,
          }}>
            <div style={{ fontSize: 10, letterSpacing: '0.22em', color: '#E86B3B', fontFamily: 'var(--font-display)', marginBottom: 4 }}>◆ COULDN'T JOIN</div>
            <div style={{ fontSize: 12, color: 'var(--text)', lineHeight: 1.45 }}>{error}</div>
          </div>
        )}

        {/* Trip preview + display-name input */}
        {phase === 'found' && tripPreview && (
          <div className="bracket" style={{
            border: '1px solid #7DE08B',
            background: 'linear-gradient(180deg, rgba(125,224,139,0.08), rgba(125,224,139,0.02))',
            padding: 16, marginBottom: 14,
          }}>
            <div style={{ fontFamily: 'var(--font-display)', fontSize: 10, letterSpacing: '0.24em', color: '#7DE08B', marginBottom: 4 }}>◆ TRIP FOUND</div>
            <div style={{ fontFamily: 'var(--font-display)', fontWeight: 700, fontSize: 18, color: 'var(--text-hi)', letterSpacing: '0.04em', marginBottom: 6 }}>
              {tripPreview.name.toUpperCase()}
            </div>
            <div style={{ fontSize: 11, color: 'var(--text-mu)', marginBottom: 12 }}>
              Started by {tripPreview.createdBy} · {tripPreview.members.length} crew
            </div>
            <div style={{ display: 'flex', gap: -6, marginBottom: 14 }}>
              {tripPreview.members.map((m, i) => (
                <div key={i} style={{ marginLeft: i ? -6 : 0, border: '1.5px solid #000', borderRadius: '50%' }}>
                  <CrewAvatar color={Object.values(PEOPLE_COLORS)[i % 5]} initial={m[0]} size={28} />
                </div>
              ))}
            </div>

            {/* Display name (mandatory) */}
            <div style={{ borderTop: '1px solid var(--line-subtle)', paddingTop: 14 }}>
              <div style={{ fontSize: 10, letterSpacing: '0.24em', color: 'var(--text-mu)', fontFamily: 'var(--font-display)', marginBottom: 6 }}>
                YOUR NAME (HOW THE CREW SEES YOU)
              </div>
              <input
                value={displayName}
                onChange={e => setDisplayName(e.target.value)}
                placeholder="e.g. Emil"
                autoCapitalize="words"
                style={{
                  background: 'rgba(10,20,32,0.5)', border: '1px solid var(--line)',
                  outline: 'none', padding: '10px 12px',
                  fontFamily: 'var(--font-display)', fontSize: 16,
                  color: 'var(--text-hi)', width: '100%', boxSizing: 'border-box',
                }}
              />
              {displayName.trim().length > 0 && displayName.trim().length < 2 && (
                <div style={{ fontSize: 10, color: '#E86B3B', marginTop: 4 }}>Name needs at least 2 characters.</div>
              )}
            </div>
          </div>
        )}

        <PrimaryBtn onClick={doJoin} pulse={canJoin} disabled={!canJoin}>
          {joining ? 'Joining…' : phase === 'found' ? `Join ${tripPreview ? tripPreview.name : 'trip'}` : 'Enter a code to continue'}
          {canJoin && <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><path d="M5 12h14M12 5l7 7-7 7" /></svg>}
        </PrimaryBtn>
      </div>
    </div>
  );
}

// ═══════════════════════════════════════════════════════════════
// DASHBOARD
// ═══════════════════════════════════════════════════════════════
function DashboardScreen({ ctx }) {
  const [tab, setTab] = React.useState('activity'); // activity | balance
  const [me] = useMe();

  const myName = ctx.myName || (me.name || 'Du');
  // Trip's home currency (frozen at create-name) and FX snapshot.
  const homeCurrency = (ctx.pot && ctx.pot.homeCurrency) || 'SEK';
  const fxRates = (ctx.pot && ctx.pot.fxRates) || null;
  // Helper: amount in home currency for a given expense (canonical for math).
  const homeAmt = (e) => (e.home != null ? Number(e.home) : Number(e.sek)) || 0;

  const totals = ctx.expenses.reduce((acc, e) => acc + homeAmt(e), 0);
  // SEK reference for the totals — derived from the trip's frozen FX snapshot.
  const totalsSek = (window.convertFx
    ? window.convertFx(totals, homeCurrency, 'SEK', fxRates, homeCurrency)
    : totals);
  // Compute per-person balance in HOME currency across the pot's actual members.
  // Each expense splits evenly across ALL current crew members (pot.members),
  // not just whoever was in splitWith when it was created — this way new joiners
  // get their share of earlier expenses without needing data backfills.
  const potMembers = (ctx.pot && ctx.pot.members && ctx.pot.members.length) ? ctx.pot.members : [myName];
  const perPerson = {};
  potMembers.forEach(p => perPerson[p] = 0);
  for (const e of ctx.expenses) {
    const amt = homeAmt(e);
    const share = amt / potMembers.length;
    for (const p of potMembers) perPerson[p] -= share;
    if (perPerson[e.paidBy] !== undefined) perPerson[e.paidBy] += amt;
  }

  // Build crew list from the pot's members (no hardcoded friends).
  const palette = [PEOPLE_COLORS.E, PEOPLE_COLORS.M, PEOPLE_COLORS.S, PEOPLE_COLORS.L, PEOPLE_COLORS.Y];
  const crews = potMembers.map((name, i) => {
    const isMe = name === myName;
    const display = name;
    return {
      name: display,
      initial: display.trim().charAt(0).toUpperCase() || '?',
      color: isMe ? PEOPLE_COLORS.Y : palette[i % palette.length],
      balance: Math.round(perPerson[name] || 0),
      isMe,
      photo: isMe ? me.photo : undefined,
    };
  });

  const catIcon = { food: '🍴', drinks: '🥃', lodging: '🏠', transit: '🚆', fuel: '⛽', tickets: '🎫', other: '•••' };
  const catLabel = { food: 'Food', drinks: 'Drinks', lodging: 'Lodging', transit: 'Travel', fuel: 'Fuel', tickets: 'Tickets', other: 'Other' };

  return (
    <div>
      <AppHeader
        back={() => ctx.go('home')}
        title={ctx.pot.name ? ctx.pot.name.toUpperCase() : 'NEW TRIP'}
        right={(() => {
          // Only render crew in the header if there's actually more than just "me".
          const others = potMembers.filter(m => m !== myName);
          return (
            <div style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
              {others.length > 0 && (
                <>
                  <div style={{ marginRight: -10 }}><MeAvatar size={22} /></div>
                  {others.map((name, i) => {
                    const paletteArr = [PEOPLE_COLORS.E, PEOPLE_COLORS.M, PEOPLE_COLORS.S, PEOPLE_COLORS.L];
                    const initial = (name.charAt(0) || '?').toUpperCase();
                    return (
                      <div key={name} style={{ marginLeft: -10 }}>
                        <CrewAvatar color={paletteArr[i % paletteArr.length]} initial={initial} size={22} />
                      </div>
                    );
                  })}
                </>
              )}
              <button onClick={() => ctx.go('invite-qr')} title="Invite" style={{
                marginLeft: 4,
                width: 22, height: 22, borderRadius: '50%',
                border: '1px dashed var(--cyan-500)',
                background: 'rgba(59,180,232,0.08)',
                color: 'var(--cyan-500)',
                display: 'flex', alignItems: 'center', justifyContent: 'center',
                padding: 0, cursor: 'pointer',
                fontFamily: 'var(--font-display)', fontSize: 14, fontWeight: 600, lineHeight: 1,
              }}>+</button>
            </div>
          );
        })()}
      />

      <div style={{ padding: '0 24px' }}>
        {/* Pot total */}
        <div className="bracket" style={{
          padding: '16px 16px 14px',
          border: '1px solid var(--line)',
          background: 'rgba(59,180,232,0.04)',
          marginBottom: 16,
        }}>
          <div style={{ fontSize: 10, letterSpacing: '0.24em', color: 'var(--text-mu)', fontFamily: 'var(--font-display)' }}>TAB TOTAL · {homeCurrency}</div>
          <div style={{ fontFamily: 'var(--font-display)', fontWeight: 700, fontSize: 42, color: 'var(--text-hi)', lineHeight: 1.05, marginTop: 2 }}>
            {Math.round(totals).toLocaleString('sv-SE').replace(/,/g, ' ')} <span style={{ fontSize: 18, color: 'var(--text-mu)' }}>{homeCurrency}</span>
          </div>
          {homeCurrency !== 'SEK' && (
            <div style={{ fontSize: 11, color: 'var(--text-mu)', fontFamily: 'var(--font-display)', letterSpacing: '0.08em', marginTop: 2 }}>
              ≈ {Math.round(totalsSek).toLocaleString('sv-SE').replace(/,/g,' ')} SEK
            </div>
          )}
          <div style={{ fontSize: 11, color: 'var(--text-mu)', marginTop: 4 }}>{ctx.expenses.length} expenses · {potMembers.length} crew</div>
        </div>

        {/* Your status */}
        <div style={{
          padding: '14px 16px',
          background: 'rgba(125,224,139,0.06)',
          border: '1px solid rgba(125,224,139,0.4)',
          marginBottom: 20,
        }}>
          <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
            <div>
              <div style={{ fontSize: 10, letterSpacing: '0.24em', color: '#7DE08B', fontFamily: 'var(--font-display)' }}>◆ YOUR BALANCE</div>
              <div style={{ fontFamily: 'var(--font-display)', fontSize: 26, fontWeight: 700, color: '#7DE08B', marginTop: 2 }}>
                {perPerson[myName] >= 0 ? '+' : ''}{Math.round(perPerson[myName] || 0).toLocaleString('sv-SE').replace(/,/g,' ')} <span style={{ fontSize: 14, opacity: 0.7 }}>{homeCurrency}</span>
              </div>
              {homeCurrency !== 'SEK' && (
                <div style={{ fontSize: 11, color: 'var(--text-mu)', fontFamily: 'var(--font-display)', letterSpacing: '0.08em', marginTop: 1 }}>
                  ≈ {(perPerson[myName] >= 0 ? '+' : '')}
                  {Math.round((window.convertFx ? window.convertFx(perPerson[myName] || 0, homeCurrency, 'SEK', fxRates, homeCurrency) : (perPerson[myName] || 0))).toLocaleString('sv-SE').replace(/,/g,' ')} SEK
                </div>
              )}
              <div style={{ fontSize: 11, color: 'var(--text)' }}>
                {perPerson[myName] >= 0 ? 'The crew owes you' : 'You owe the crew'}
              </div>
            </div>
            <button onClick={() => ctx.go('settle')} style={{
              padding: '10px 14px', border: '1px solid #7DE08B',
              background: 'rgba(125,224,139,0.1)', color: '#7DE08B',
              fontFamily: 'var(--font-display)', letterSpacing: '0.18em', fontSize: 11, cursor: 'pointer',
              fontWeight: 600,
            }}>SETTLE →</button>
          </div>
        </div>

        {/* Tabs */}
        <div style={{ display: 'flex', gap: 0, marginBottom: 14, border: '1px solid var(--line-subtle)' }}>
          {[['activity','EXPENSES'],['balance','BALANCES']].map(([k, label]) => (
            <button key={k} onClick={() => setTab(k)} style={{
              flex: 1, padding: '10px',
              background: tab === k ? 'rgba(59,180,232,0.1)' : 'transparent',
              border: 'none', cursor: 'pointer',
              color: tab === k ? 'var(--cyan-100)' : 'var(--text-mu)',
              fontFamily: 'var(--font-display)', letterSpacing: '0.2em', fontSize: 11, fontWeight: 600,
              borderRight: k === 'activity' ? '1px solid var(--line-subtle)' : 'none',
            }}>{label}</button>
          ))}
        </div>

        {tab === 'activity' ? (
          ctx.expenses.length === 0 ? (
            <button onClick={() => ctx.go('add-expense')} style={{
              width: '100%',
              display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center',
              gap: 14,
              padding: '36px 20px 32px',
              marginBottom: 80,
              background: 'linear-gradient(180deg, rgba(59,180,232,0.08), rgba(59,180,232,0.02))',
              border: '1.5px dashed var(--cyan-500)',
              color: 'var(--cyan-100)',
              cursor: 'pointer',
              fontFamily: 'var(--font-display)',
            }}>
              <div style={{
                width: 54, height: 54, borderRadius: '50%',
                border: '1.5px solid var(--cyan-500)',
                background: 'linear-gradient(180deg, rgba(59,180,232,0.3), rgba(59,180,232,0.1))',
                display: 'flex', alignItems: 'center', justifyContent: 'center',
                fontSize: 28, fontWeight: 300, lineHeight: 1,
              }}>+</div>
              <div style={{ textAlign: 'center' }}>
                <div style={{ fontSize: 14, fontWeight: 700, letterSpacing: '0.2em', color: 'var(--cyan-100)', marginBottom: 4 }}>
                  ADD FIRST EXPENSE
                </div>
                <div style={{ fontSize: 11, color: 'var(--text-mu)', letterSpacing: '0.06em', textTransform: 'none', fontFamily: 'var(--font-ui)' }}>
                  Start tracking what the crew spends
                </div>
              </div>
            </button>
          ) : (
          <div style={{ display: 'flex', flexDirection: 'column', gap: 6, marginBottom: 80 }}>
            {ctx.expenses.map(e => (
              <div key={e.id} style={{
                display: 'flex', alignItems: 'center', gap: 10,
                padding: '10px 12px', borderBottom: '1px solid var(--line-subtle)',
              }}>
                <div style={{
                  width: 34, height: 34, border: '1px solid var(--line)',
                  display: 'flex', alignItems: 'center', justifyContent: 'center',
                  fontSize: 16, flexShrink: 0,
                }}>{catIcon[e.cat]}</div>
                <div style={{ flex: 1, minWidth: 0 }}>
                  <div style={{ fontSize: 13, color: 'var(--text-hi)', fontWeight: 500 }}>{e.desc}</div>
                  <div style={{ fontSize: 10, color: 'var(--text-mu)', fontFamily: 'var(--font-display)', letterSpacing: '0.1em', textTransform: 'uppercase' }}>
                    {catLabel[e.cat] || 'Other'} · {e.paidBy} · {e.date}
                  </div>
                </div>
                <div style={{ textAlign: 'right' }}>
                  <div style={{ fontFamily: 'var(--font-display)', fontWeight: 700, fontSize: 14, color: 'var(--text-hi)' }}>
                    {Math.round(homeAmt(e)).toLocaleString('sv-SE').replace(/,/g,' ')} {homeCurrency}
                  </div>
                  {e.currency && e.currency !== homeCurrency && (
                    <div style={{ fontSize: 10, color: 'var(--text-mu)', fontFamily: 'var(--font-display)' }}>
                      {Number(e.amount || 0).toLocaleString('sv-SE').replace(/,/g,' ')} {e.currency}
                    </div>
                  )}
                  {homeCurrency !== 'SEK' && e.sek != null && (
                    <div style={{ fontSize: 10, color: 'var(--text-mu)', fontFamily: 'var(--font-display)' }}>
                      ≈ {Math.round(Number(e.sek)).toLocaleString('sv-SE').replace(/,/g,' ')} SEK
                    </div>
                  )}
                </div>
              </div>
            ))}
          </div>
          )
        ) : (
          <div style={{ display: 'flex', flexDirection: 'column', gap: 8, marginBottom: 80 }}>
            {crews.map((p, i) => (
              <div key={i} style={{
                display: 'flex', alignItems: 'center', gap: 12,
                padding: '12px 14px', background: 'rgba(10,20,32,0.5)',
                border: '1px solid var(--line-subtle)',
              }}>
                <CrewAvatar color={p.color} initial={p.initial} size={32} photo={p.photo} />
                <div style={{ flex: 1 }}>
                  <div style={{ fontSize: 13, color: 'var(--text-hi)', fontWeight: 500 }}>{p.name}</div>
                  <div style={{ fontSize: 10, color: 'var(--text-mu)', fontFamily: 'var(--font-display)', letterSpacing: '0.14em' }}>
                    {p.balance > 0 ? 'GETS BACK' : p.balance < 0 ? 'OWES' : 'EVEN'}
                  </div>
                </div>
                <div style={{
                  fontFamily: 'var(--font-display)', fontWeight: 700, fontSize: 18,
                  color: p.balance > 0 ? '#7DE08B' : p.balance < 0 ? '#E86B3B' : 'var(--text-mu)',
                }}>
                  {p.balance > 0 ? '+' : ''}{p.balance.toLocaleString('sv-SE').replace(/,/g,' ')} <span style={{ fontSize: 11, opacity: 0.7 }}>{homeCurrency}</span>
                </div>
              </div>
            ))}
          </div>
        )}
      </div>

      {/* Floating add */}
      <button onClick={() => ctx.go('add-expense')} className="pulse" style={{
        position: 'fixed', right: 20, bottom: 56,
        width: 60, height: 60,
        borderRadius: '50%', border: '1.5px solid var(--cyan-500)',
        background: 'linear-gradient(180deg, rgba(59,180,232,0.3), rgba(59,180,232,0.1))',
        color: 'var(--cyan-100)', cursor: 'pointer',
        fontSize: 32, fontFamily: 'var(--font-display)', fontWeight: 300,
        display: 'flex', alignItems: 'center', justifyContent: 'center',
        zIndex: 100,
      }}>+</button>
    </div>
  );
}

Object.assign(window, { JoinScreen, DashboardScreen });
