/* ==========================================================================
   Flappy Bird — themed to the innomate design system
   (public/innomate-design-system: dark-first black surfaces, one steel-blue
   accent, Montserrat + Gridular numerals, pill buttons, hairline cards).
   ========================================================================== */

:root {
  /* Surfaces — dark-first */
  --background: #000000;
  --ink-soft: #0D0D0D;
  --card: #0A0A0A;
  --muted: #141414;

  /* Text */
  --foreground: #FAFAFA;
  --muted-foreground: #A6A6A6;

  /* Brand — single blue accent */
  --primary: #5095B6;
  --primary-glow: #7FB0C9;
  --secondary: #052F4E;

  /* Lines & controls */
  --hairline: rgba(255, 255, 255, 0.08);
  --card-fill: rgba(255, 255, 255, 0.03);
  --input-border: rgba(255, 255, 255, 0.15);

  /* Radius */
  --radius: 0.25rem;
  --radius-card: 16px;
  --radius-pill: 9999px;

  /* Elevation & motion */
  --shadow-glow: 0 0 80px hsl(201 38% 51% / 0.35);
  --shadow-elegant: 0 30px 80px -20px hsl(0 0% 0% / 0.7);
  --ease-smooth: cubic-bezier(0.22, 1, 0.36, 1);

  /* Type */
  --font-sans: 'Montserrat', system-ui, -apple-system, sans-serif;
  --font-accent: 'Gridular', 'Montserrat', ui-monospace, monospace; /* numerals */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-sans);
  background: var(--background);
  color: var(--foreground);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
  touch-action: manipulation;
}

/* Display heading — Montserrat, tight tracking (per DS typography). */
.title,
.landing h1 {
  font-family: var(--font-sans);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--foreground);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.55), 0 0 60px hsl(201 38% 51% / 0.35);
}

/* ---------- Game stage (mobile + host) ---------- */
.stage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--background);
}

canvas#game {
  display: block;
  width: 100%;
  height: 100%;
}

/* Overlay panels drawn in HTML on top of the canvas. */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
  gap: 20px;
  padding: 24px;
}
.overlay.hidden { display: none; }
/* When an overlay carries a tall panel (e.g. the game-over lead form) let it
   scroll from the top instead of clipping a centred block on short screens. */
.overlay.scrolls {
  justify-content: flex-start;
  overflow-y: auto;
  padding-top: max(env(safe-area-inset-top, 0px), 7vh);
  padding-bottom: 7vh;
}

.overlay .title { font-size: clamp(30px, 8vw, 56px); }
.overlay .sub { font-size: 16px; color: var(--muted-foreground); }

/* Live score — Gridular/mono numerals, kept bright to read over the sky. */
.hud-score {
  position: absolute;
  top: 7%;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--font-accent);
  font-size: clamp(44px, 12vw, 76px);
  font-weight: 600;
  color: var(--foreground);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8), 0 0 40px hsl(201 38% 51% / 0.55);
  pointer-events: none;
}

/* Persistent innomate wordmark — a light-touch brand mark pinned to the
   top-centre of the screen, so it reads on the lobby and stays put during
   play. White SVG, so a soft dark glow keeps it legible over the bright sky.
   The safe-area inset keeps it clear of notches on phones. */
.brand-mark {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 32px);
  left: 50%;
  transform: translateX(-50%);
  height: clamp(16px, 2.6vh, 24px);
  width: auto;
  opacity: 0.82;
  pointer-events: none;
  z-index: 5;
  filter: drop-shadow(0 1px 6px rgba(0, 0, 0, 0.85));
}

/* On the phone controller the mark sits on its own centred row at the very
   top, above the status/score bar, so it never collides with status text. */
.controller .brand-mark {
  position: static;
  transform: none;
  align-self: center;
  height: 16px;
  opacity: 0.7;
  margin-top: 16px;
  margin-bottom: 12px;
}

/* Hairline content card (DS card). Darker, opaque fill because it floats over
   the bright game sky — the translucent .03 card-fill is only legible on black. */
.panel {
  pointer-events: auto;
  background: rgba(10, 10, 10, 0.8);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  padding: 20px 24px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow-elegant);
  min-width: 240px;
}
.panel .row {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  font-size: 15px;
  margin: 8px 0;
  color: var(--muted-foreground);
}
.panel .row b {
  font-family: var(--font-accent);
  font-weight: 600;
  color: var(--primary-glow);
}

/* Pill button — DS primary (white → brand-blue on hover). */
.btn {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 26px;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #000;
  background: var(--foreground);
  border: 0;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.3s var(--ease-smooth);
}
.btn:hover { background: var(--primary); color: #000; box-shadow: 0 0 60px hsl(201 38% 51% / 0.35); }
.btn:active { transform: translateY(1px); }
.btn.secondary {
  color: var(--foreground);
  background: transparent;
  border: 1px solid var(--input-border);
}
.btn.secondary:hover { background: transparent; border-color: rgba(255, 255, 255, 0.4); box-shadow: none; }

/* Ready hint — eyebrow-style caption, legible over the bright sky. */
.hint {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--foreground);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.85);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:.5} 50%{opacity:1} }

/* ---------- Landing / mode selector ---------- */
.landing {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 32px;
  background:
    radial-gradient(90% 60% at 50% 0%, hsl(201 38% 51% / 0.14), transparent 60%),
    var(--background);
  color: var(--foreground);
}
.landing h1 { font-size: clamp(34px, 9vw, 62px); margin: 0; }
.landing p {
  max-width: 520px;
  text-align: center;
  line-height: 1.6;
  margin: 0;
  font-size: 16px;
  color: var(--muted-foreground);
}
.cards { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.card {
  background: var(--card-fill);
  color: var(--foreground);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  padding: 22px;
  width: 260px;
  text-decoration: none;
  transition: all 0.3s var(--ease-smooth);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card:hover {
  transform: translateY(-4px);
  border-color: hsl(201 38% 51% / 0.5);
  box-shadow: var(--shadow-glow);
}
.card .emoji { font-size: 26px; opacity: 0.9; }
.card h2 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.02em; color: var(--foreground); }
.card small { color: var(--muted-foreground); line-height: 1.5; font-size: 13px; }

/* ---------- Host (desktop) lobby ---------- */
.lobby {
  pointer-events: auto;
  background: rgba(10, 10, 10, 0.82); /* opaque: floats over the bright game sky */
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 360px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow-elegant);
  color: var(--muted-foreground);
}
.lobby > div:first-child { font-size: 13px; }
.lobby .qr {
  background: #fff;
  padding: 14px;
  border-radius: 12px;
  line-height: 0;
  box-shadow: var(--shadow-glow);
}
.lobby .qr canvas, .lobby .qr img { display: block; width: 232px; height: 232px; }
.lobby .qr img[hidden] { display: none; } /* honor the hidden attr over display:block */

/* Loading state while the room + QR are being generated (also covers a Render
   cold start), so the empty box never reads as an error. */
.qr-loading {
  width: 232px;
  height: 232px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  line-height: normal;
}
.qr-loading[hidden] { display: none; }
.spinner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 4px solid rgba(80, 149, 182, 0.25);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.qr-loading-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: #52708a;
}
.lobby .url { font-size: 12px; opacity: 0.7; word-break: break-all; text-align: center; }

/* Status dot — brand blue when live, muted otherwise (single-accent system). */
.status-dot {
  display: inline-block;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted-foreground);
  margin-right: 8px; vertical-align: middle;
  transition: all 0.3s var(--ease-smooth);
}
.status-dot.on {
  background: var(--primary);
  box-shadow: 0 0 12px hsl(201 38% 51% / 0.9);
}

/* "N waiting" — DS badge (brand tint). */
.waiting-badge {
  position: absolute;
  top: 16px; right: 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: hsl(201 38% 51% / 0.1);
  border: 1px solid hsl(201 38% 51% / 0.3);
  color: var(--primary-glow);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  pointer-events: none;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.waiting-badge.hidden { display: none; }

/* ---------- Controller (phone) ---------- */
.controller {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(90% 50% at 50% 0%, hsl(201 38% 51% / 0.14), transparent 55%),
    var(--background);
  color: var(--foreground);
  padding: 18px;
}
.controller .top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted-foreground);
}
.controller .score-badge {
  font-family: var(--font-accent);
  font-size: 22px; font-weight: 600; color: var(--primary-glow);
}

/* Hero action — the brand-blue CTA with ambient glow. */
.flap-btn {
  flex: 1;
  margin: 18px 0;
  border: 0;
  border-radius: 28px;
  background: var(--primary);
  color: var(--secondary);
  font-family: var(--font-sans);
  font-size: clamp(38px, 13vw, 72px);
  font-weight: 800;
  letter-spacing: -0.02em;
  cursor: pointer;
  box-shadow: var(--shadow-glow), inset 0 1px 0 hsl(201 38% 65% / 0.6);
  transition: transform 0.06s var(--ease-smooth), box-shadow 0.2s var(--ease-smooth), background 0.2s ease;
  display: flex; align-items: center; justify-content: center;
  text-transform: uppercase;
}
.flap-btn:active {
  transform: translateY(3px) scale(0.99);
  background: var(--primary-glow);
  box-shadow: 0 0 30px hsl(201 38% 51% / 0.3);
}
.flap-btn:disabled {
  background: var(--muted);
  color: var(--muted-foreground);
  box-shadow: none;
  cursor: default;
}
.controller .bottom { display: flex; gap: 12px; }
.controller .bottom .btn { flex: 1; }

.toast {
  position: fixed;
  left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink-soft);
  border: 1px solid var(--hairline);
  color: var(--foreground);
  padding: 12px 18px; border-radius: 12px; font-size: 14px;
  box-shadow: var(--shadow-elegant);
  opacity: 0; transition: opacity 0.25s var(--ease-smooth); pointer-events: none;
}
.toast.show { opacity: 1; }

/* ---------- Lead-capture form (demo mockup) ----------
   Shown on the phone once the run ends. This is a UI mock only — it never
   submits anywhere, stores nothing, and sends nothing to any CRM. The copy in
   .lead-note makes that explicit to the player. */
.lead-form {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.lead-form.hidden { display: none; }

/* On the phone controller the form fills the padded flex column, not an
   absolutely-positioned game stage, so let it flow in the normal layout. */
.controller .lead-form {
  position: static;
  inset: auto;
  flex: 1;
  margin: 12px 0;
  padding: 0;
  background: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.lead-card {
  pointer-events: auto;
  width: 100%;
  max-width: 360px;
  background: rgba(10, 10, 10, 0.9);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  padding: 26px 24px;
  box-shadow: var(--shadow-elegant);
  text-align: left;
}
.controller .lead-card { max-width: 100%; }

.lead-card .lead-title {
  font-family: var(--font-sans);
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: 22px;
  margin: 0 0 6px;
  color: var(--foreground);
}
/* Final score / best, folded into the same card as the form (DS mono numerals,
   framed by hairlines so it reads as a distinct results row). */
.lead-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 18px;
  padding: 14px 0;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
}
.lead-results .row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 15px;
  color: var(--muted-foreground);
}
.lead-results .row b {
  font-family: var(--font-accent);
  font-weight: 600;
  font-size: 18px;
  color: var(--primary-glow);
}

.lead-card form { display: flex; flex-direction: column; gap: 6px; }
.lead-label {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8);
  margin: 12px 0 0;
}
.lead-input {
  width: 100%;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--input-border);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--foreground);
  font-size: 16px; /* 16px avoids iOS zoom-on-focus */
  font-family: var(--font-sans);
  outline: none;
  -webkit-user-select: text;
  user-select: text;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.lead-input::placeholder { color: rgba(255, 255, 255, 0.3); }
.lead-input:focus { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }

/* Submit is intentionally grayed out — it's a demo control. It stays tappable
   so a tap can reveal the "this is a demo form" note. */
.lead-card .lead-submit {
  width: 100%;
  margin-top: 20px;
  background: rgba(255, 255, 255, 0.09);
  color: var(--muted-foreground);
  box-shadow: none;
}
.lead-card .lead-submit:hover {
  background: rgba(255, 255, 255, 0.14);
  color: var(--foreground);
  box-shadow: none;
}
.lead-card .lead-restart {
  width: 100%;
  margin-top: 10px;
  min-height: 42px;
  font-size: 14px;
}

/* Privacy note — the honest "this is only a mockup" disclaimer. */
.lead-note {
  display: flex;
  gap: 8px;
  font-size: 12px;
  line-height: 1.5;
  font-weight: 400;
  color: var(--muted-foreground);
  background: hsl(201 38% 51% / 0.08);
  border: 1px solid hsl(201 38% 51% / 0.22);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 18px 0 0;
}
.lead-note .lock { flex: none; }

/* Post-submit confirmation — an inline banner that appears below the form
   while the fields stay on screen (nothing is actually sent). */
.lead-success {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--foreground);
  background: hsl(201 38% 51% / 0.14);
  border: 1px solid hsl(201 38% 51% / 0.4);
  border-radius: 10px;
  padding: 11px 13px;
  margin-top: 16px;
}
.lead-success .check { flex: none; }
