:root {
  --bg: #0b0b12;
  --panel: #16161f;
  --panel-2: #1e1e2a;
  --text: #f2f2f7;
  --muted: #9a9aad;
  --accent: #ff2d78;
  --accent-2: #7c4dff;
  --ok: #2ecc71;
  --err: #ff5252;
  --radius: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

/* ---------- landing ---------- */

.landing {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
}

.landing h1 {
  font-size: 2rem;
  margin: 0 0 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.landing p.sub { color: var(--muted); margin: 0 0 24px; max-width: 420px; }

.role-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  width: min(420px, 100%);
  padding: 20px 22px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid #2a2a3a;
  text-align: left;
  transition: transform .1s ease, border-color .15s ease;
}
.role-btn:active { transform: scale(.98); }
.role-btn .emoji { font-size: 2.2rem; }
.role-btn .title { font-size: 1.15rem; font-weight: 600; }
.role-btn .desc { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.role-btn.player { border-color: #3b2437; }
.role-btn.clicker { border-color: #2b2447; }

.footer-note { color: var(--muted); font-size: .8rem; margin-top: 24px; }
.footer-note a { color: var(--muted); }

/* ---------- shared bits ---------- */

.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--err);
  vertical-align: middle;
}
.status-dot.on { background: var(--ok); }

.chip {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: 10px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(20, 20, 30, .75);
  backdrop-filter: blur(8px);
  border: 1px solid #2a2a3a;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: .85rem;
  color: var(--muted);
  cursor: pointer;
}
.chip b { color: var(--text); letter-spacing: .1em; }

/* ---------- player feed ---------- */

.feed {
  height: 100dvh;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
}
.feed::-webkit-scrollbar { display: none; }

.slide {
  position: relative;
  height: 100dvh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.slide iframe {
  width: 100%;
  height: 100%;
  border: 0;
  pointer-events: none; /* swipes/taps stay ours; playback is driven remotely */
}

.slide .demo-card {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 5rem;
}
.slide .demo-card .num { font-size: 1.2rem; color: rgba(255,255,255,.85); }

.slide .caption {
  position: absolute;
  left: 16px;
  bottom: calc(24px + env(safe-area-inset-bottom));
  right: 90px;
  font-size: .95rem;
  text-shadow: 0 1px 4px rgba(0,0,0,.8);
}

/* pairing overlay */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(8, 8, 14, .96);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
}
.overlay.hidden { display: none; }
.overlay h2 { margin: 0; font-size: 1.3rem; }
.overlay .pair-code {
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: .18em;
  color: var(--accent);
}
.overlay .qr {
  background: #fff;
  padding: 12px;
  border-radius: 12px;
  line-height: 0;
}
.overlay .qr img { width: 180px; height: 180px; image-rendering: pixelated; }
.overlay .hint { color: var(--muted); font-size: .9rem; max-width: 340px; }
.overlay .share-link {
  color: var(--accent-2);
  font-size: .85rem;
  word-break: break-all;
  max-width: 90vw;
}

.pill-btn {
  background: var(--panel-2);
  border: 1px solid #2f2f42;
  border-radius: 999px;
  padding: 10px 20px;
  font-size: .95rem;
}
.pill-btn.primary { background: var(--accent); border-color: var(--accent); font-weight: 600; }

.player-toolbar {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  right: 10px;
  z-index: 40;
  display: flex;
  gap: 8px;
}
.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(20,20,30,.75);
  border: 1px solid #2a2a3a;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* settings sheet */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet.hidden { display: none; }
.sheet-body {
  width: min(560px, 100%);
  max-height: 85dvh;
  overflow-y: auto;
  background: var(--panel);
  border-radius: 20px 20px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sheet-body h3 { margin: 0; }
.sheet-body p { margin: 0; color: var(--muted); font-size: .88rem; }
.sheet-body textarea {
  width: 100%;
  min-height: 140px;
  resize: vertical;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid #2f2f42;
  border-radius: 12px;
  padding: 12px;
  font: inherit;
  font-size: .85rem;
}
.sheet-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- clicker ---------- */

.clicker-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 16px;
  padding-top: calc(16px + env(safe-area-inset-top));
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  gap: 14px;
}

.clicker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: .9rem;
}
.clicker-header .code-label b { color: var(--text); letter-spacing: .12em; }

.join-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
}
.join-form h2 { margin: 0; }
.join-form p { color: var(--muted); margin: 0; max-width: 320px; }
.code-input {
  width: 240px;
  text-align: center;
  font-size: 2rem;
  letter-spacing: .35em;
  padding: 14px 0 14px .35em;
  border-radius: 14px;
  border: 1px solid #2f2f42;
  background: var(--panel-2);
  color: var(--text);
}
.code-input:focus { outline: 2px solid var(--accent-2); }
.join-error { color: var(--err); font-size: .9rem; min-height: 1.2em; margin: 0; }

.big-btn {
  background: var(--accent);
  border-radius: 16px;
  padding: 16px 34px;
  font-size: 1.1rem;
  font-weight: 700;
}

.pad-wrap { flex: 1; display: flex; flex-direction: column; gap: 14px; }
.pad-wrap.hidden, .join-form.hidden { display: none; }

.tap-pad {
  flex: 1;
  border-radius: 24px;
  background: radial-gradient(circle at 50% 35%, #241a3a, var(--panel));
  border: 1px solid #2f2f42;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.tap-pad .arrow { font-size: 4rem; line-height: 1; }
.tap-pad .label { color: var(--muted); }
.tap-pad:active { background: radial-gradient(circle at 50% 35%, #33245a, var(--panel-2)); }
.tap-pad.flash { border-color: var(--accent); }

.aux-row { display: flex; gap: 12px; }
.aux-btn {
  flex: 1;
  padding: 18px 0;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid #2f2f42;
  font-size: 1.4rem;
}
.aux-btn:active { background: var(--panel-2); }

.pos-indicator { text-align: center; color: var(--muted); font-size: .9rem; min-height: 1.2em; }
