:root {
  --bg: #0b0b10;
  --panel: #16161f;
  --line: #2a2a38;
  --text: #f4f4f8;
  --muted: #9a9ab0;
  --accent: #ffd23f;
  --ink: #141414;
  --danger: #ff4d5e;
  --good: #3ddc84;
  --glass: rgba(16, 16, 24, 0.55);
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
body { overflow: hidden; }
a { color: inherit; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:disabled { opacity: 0.4; cursor: default; }
[hidden] { display: none !important; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 8px var(--good); margin-right: 6px; vertical-align: 1px; }

/* Onboarding: sign in, profile, home. Bright, bold and playful. */
.onboard { height: 100%; overflow-y: auto; display: grid; place-items: center; padding: calc(24px + var(--top)) 20px calc(24px + var(--bottom));
  background: var(--accent); color: var(--ink); color-scheme: light; }
.card { width: min(400px, 100%); }
.card.center { text-align: center; }
.mark { width: 64px; height: 64px; border-radius: 18px; box-shadow: 0 6px 0 rgba(0, 0, 0, 0.18); }
.mark.big { width: 96px; height: 96px; border-radius: 26px; }
.logo { margin: 14px 0 0; font-size: 52px; line-height: 1; font-weight: 900; letter-spacing: -0.05em; }
.title { margin: 0; font-size: 36px; font-weight: 900; letter-spacing: -0.03em; }
.tagline { margin: 10px 0 4px; font-size: 19px; font-weight: 600; }
.hello { margin: 14px 0 4px; font-size: 19px; font-weight: 700; }
.online { margin: 0 0 24px; font-size: 14px; font-weight: 600; opacity: 0.75; min-height: 1.45em; }
.online .dot { background: #12a150; box-shadow: none; }

.providers { display: grid; gap: 10px; }
.provider { display: flex; align-items: center; justify-content: center; gap: 10px; height: 56px; border-radius: 999px; font-weight: 800; font-size: 17px; text-decoration: none;
  border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); }
.provider:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.provider svg { width: 22px; height: 22px; fill: currentColor; stroke: none; }
.provider.apple, .provider.tiktok { background: var(--ink); color: #fff; }
.provider.google { background: #fff; color: var(--ink); }
.or { display: flex; align-items: center; gap: 12px; margin: 18px 0; font-weight: 700; font-size: 14px; opacity: 0.7; }
.or::before, .or::after { content: ""; flex: 1; height: 2px; background: currentColor; opacity: 0.35; }

.stack { display: grid; gap: 10px; }
.onboard input:not([type="checkbox"]) { width: 100%; height: 56px; padding: 0 20px; border-radius: 999px; border: 3px solid var(--ink); background: #fff; color: var(--ink);
  font: inherit; font-size: 17px; font-weight: 600; outline: none; }
.onboard input:not([type="checkbox"]):focus { box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.15); }
#code { text-align: center; font-size: 26px; letter-spacing: 0.4em; font-variant-numeric: tabular-nums; }
.sent { margin: 0; font-weight: 600; }
.primary { width: 100%; height: 56px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 18px; font-weight: 800; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3); }
.primary:not(:disabled):active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3); }
.primary.big { height: 68px; font-size: 22px; }
.secondary { width: 100%; height: 56px; margin-top: 12px; border-radius: 999px; border: 3px solid var(--ink); background: #fff; color: var(--ink); font-size: 18px; font-weight: 800; box-shadow: 0 4px 0 var(--ink); }
.secondary.big { height: 64px; font-size: 20px; }
.secondary:not(:disabled):active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.link { padding: 6px; font-weight: 700; text-decoration: underline; color: inherit; }
.error { color: #b3001b; font-weight: 700; min-height: 1.45em; margin: 12px 0 0; text-align: center; }
.fine { margin: 16px 0 0; text-align: center; font-size: 13px; font-weight: 600; opacity: 0.75; }
.fine .link { padding: 0; font-size: inherit; }

.field { display: block; margin: 20px 0 8px; font-weight: 800; }
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.choices button { height: 52px; border-radius: 999px; border: 3px solid var(--ink); background: #fff; font-weight: 800; }
.choices button[aria-checked="true"] { background: var(--ink); color: #fff; }
.rules { margin: 22px 0 16px; padding: 16px 16px 16px 34px; background: rgba(255, 255, 255, 0.55); border-radius: 20px; font-weight: 600; }
.rules li + li { margin-top: 6px; }
.check { -webkit-tap-highlight-color: transparent; display: flex; gap: 12px; align-items: flex-start; margin-bottom: 18px; font-weight: 600; cursor: pointer; }
.check input { appearance: none; -webkit-appearance: none; width: 26px; height: 26px; margin: 0; flex: none; display: grid; place-content: center; cursor: pointer;
  border: 3px solid var(--ink); border-radius: 8px; background: #fff; transition: background-color 150ms ease-out; }
.check input:checked { background: var(--ink); }
.check input:checked::after { content: ""; width: 11px; height: 6px; border: solid #fff; border-width: 0 0 3px 3px; transform: translateY(-1px) rotate(-45deg); }

/* Call: you on the left, the other person on the right, controls floating over both. */
.call { position: fixed; inset: 0; background: #000; overflow: hidden; user-select: none; -webkit-user-select: none; }
.stage { position: absolute; inset: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; background: #000; }
/* Each side is a column: you and your squad on the left, the other side on the right. */
.col { position: relative; display: flex; flex-direction: column; gap: 3px; min-width: 0; overflow: hidden; background: #111; }
#theirs { transition: transform 0.2s; }
#theirs.dragging { transition: none; }
.tile { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #111; }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #111; }
#local.mirror { transform: scaleX(-1); }
#local.off { opacity: 0.2; }
.label { position: absolute; z-index: 2; left: 8px; bottom: 8px; max-width: calc(100% - 20px); padding: 4px 10px; border-radius: 999px;
  background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col > .tile:last-child .label { bottom: calc(96px + var(--bottom)); }
.call:not(.in-call) .only-call { display: none !important; }

.overlay { position: absolute; inset: 0; z-index: 1; display: grid; place-content: center; justify-items: center; gap: 16px; text-align: center; padding: 16px;
  background: radial-gradient(90% 60% at 50% 40%, #2b2410 0%, #0a0a0a 75%); }
.overlay p { margin: 0; font-size: 17px; font-weight: 600; color: #e8e8ee; max-width: 280px; }
.spinner { width: 52px; height: 52px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, 0.12); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
.overlay.idle .spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.top { position: absolute; z-index: 4; left: 0; right: 0; top: 0; padding: calc(12px + var(--top)) 12px 12px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 8px;
  background: linear-gradient(rgba(0, 0, 0, 0.55), transparent); pointer-events: none; }
.top > * { pointer-events: auto; }
.top > .pill { justify-self: start; }
.top > #squad-pill { justify-self: end; }
.pill { display: inline-flex; align-items: center; height: 40px; padding: 0 14px; border-radius: 999px; background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); font-size: 14px; font-weight: 700; white-space: nowrap; }
.round { position: relative; width: 48px; height: 48px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.round.small { width: 40px; height: 40px; }
.round.small svg { width: 20px; height: 20px; }
.round.off { background: #fff; color: #111; }
.round.danger { color: var(--danger); }

.timer { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.clock { min-width: 84px; height: 40px; padding: 0 16px; display: grid; place-items: center; border-radius: 999px; background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  font-size: 20px; font-weight: 900; font-variant-numeric: tabular-nums; }
.clock.low { background: var(--danger); }
.more { height: 38px; padding: 0 18px; border-radius: 999px; background: var(--accent); color: var(--ink); font-weight: 900; font-size: 15px; box-shadow: 0 3px 0 #b8940f; }
.more.asked { background: var(--glass); color: var(--text); box-shadow: none; }
.more.wanted { animation: pulse 0.9s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(255, 210, 63, 0.25); } }

.controls { position: absolute; z-index: 4; left: 0; right: 0; bottom: 0; padding: 40px 14px calc(14px + var(--bottom)); display: flex; align-items: center; gap: 10px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.65)); }
.controls .next { margin-left: auto; height: 64px; padding: 0 30px; border-radius: 999px; background: var(--accent); color: var(--ink); font-size: 20px; font-weight: 900;
  display: inline-flex; align-items: center; gap: 6px; box-shadow: 0 4px 0 #b8940f; }
.controls .next svg { width: 22px; height: 22px; stroke-width: 3; }
.controls .next:not(:disabled):active { transform: translateY(3px); box-shadow: 0 1px 0 #b8940f; }
@media (max-width: 420px) {
  .controls { gap: 6px; padding-left: 10px; padding-right: 10px; }
  .controls .round { width: 42px; height: 42px; }
  .controls .round svg { width: 20px; height: 20px; }
  .controls .next { height: 56px; padding: 0 18px; font-size: 18px; }
}

.chat { position: absolute; z-index: 5; left: 12px; right: 72px; bottom: calc(132px + var(--bottom)); display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.call.keyboard .chat { bottom: calc(12px + var(--kb)); }
.messages { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; max-height: 34vh; overflow-y: auto; scrollbar-width: none; }
.messages.overflow { -webkit-mask-image: linear-gradient(transparent, #000 40px); mask-image: linear-gradient(transparent, #000 40px); }
.messages li { max-width: 78%; padding: 8px 13px; border-radius: 18px; background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  overflow-wrap: anywhere; align-self: flex-start; font-weight: 600; animation: pop 0.15s ease-out; transform-origin: bottom left; }
.messages li.mine { align-self: flex-end; background: var(--accent); color: var(--ink); }
.messages li b { color: var(--accent); }
/* Scale down, not translate: a shifted bubble briefly overflows the list and trips the fade mask. */
@keyframes pop { from { transform: scale(0.96); opacity: 0; } }
.chat-bar { display: flex; gap: 8px; pointer-events: auto; }
.chat-bar input { flex: 1; min-width: 0; height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.15); background: rgba(16, 16, 24, 0.85);
  color: var(--text); font: inherit; font-size: 16px; outline: none; }
.chat-bar input:focus { border-color: var(--accent); }
.chat-bar .send { width: 44px; height: 44px; background: var(--accent); color: var(--ink); }
.call.keyboard .controls, .call.keyboard .rail, .call.keyboard .label { visibility: hidden; }
.badge { position: absolute; top: 4px; right: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--danger); border: 2px solid #000; }

.rail { position: absolute; z-index: 4; right: 12px; bottom: calc(96px + var(--bottom)); display: flex; flex-direction: column; gap: 10px; }




.toast { position: absolute; z-index: 9; left: 50%; top: 40%; transform: translateX(-50%); padding: 10px 18px; border-radius: 999px; background: rgba(0, 0, 0, 0.8); font-weight: 700; pointer-events: none; text-align: center; max-width: 90vw; }
.hint { position: absolute; z-index: 2; left: 75%; top: 50%; transform: translateX(-50%); width: max-content; max-width: 45%; padding: 8px 14px; border-radius: 999px; text-align: center;
  background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); font-size: 14px; font-weight: 700; pointer-events: none; animation: fade 4s forwards; }
@keyframes fade { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }

/* Text pages: terms and privacy */
.doc { height: auto; overflow: auto; }
.doc main { max-width: 680px; margin: 0 auto; padding: calc(28px + var(--top)) 20px calc(40px + var(--bottom)); }
.doc .logo { font-size: 30px; text-decoration: none; color: var(--text); }
.doc h1 { margin-top: 28px; }
.doc h2 { margin-top: 28px; font-size: 19px; }
.doc li + li { margin-top: 6px; }
.doc p, .doc li { color: #d6d6e2; }
.doc a { color: var(--accent); }
.doc .logo span { color: var(--accent); }

/* Squad panel, over the right side of the call screen while forming a squad. */
.squad-panel { position: absolute; inset: 0; z-index: 3; overflow-y: auto; display: grid; place-content: center; gap: 12px; padding: calc(70px + var(--top)) 16px calc(110px + var(--bottom));
  background: var(--accent); color: var(--ink); text-align: center; }
.squad-panel h2 { margin: 0; font-size: 28px; font-weight: 900; letter-spacing: -0.02em; }
.squad-panel p { margin: 4px 0 8px; font-weight: 600; }
.squad-panel .primary { margin-top: 4px; }
.squad-panel .or { margin: 14px 0; }
.squad-panel .join { display: grid; gap: 8px; }
.squad-panel input { width: 100%; height: 52px; padding: 0 16px; border-radius: 999px; border: 3px solid var(--ink); background: #fff; color: var(--ink); font: inherit; font-size: 20px;
  font-weight: 800; text-align: center; letter-spacing: 0.25em; outline: none; }
.squad-panel .code { font-size: 44px; font-weight: 900; letter-spacing: 0.15em; font-variant-numeric: tabular-nums; user-select: all; -webkit-user-select: all; }
.members { list-style: none; margin: 4px 0 8px; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.members li { padding: 6px 14px; border-radius: 999px; background: var(--ink); color: #fff; font-weight: 800; }
.squad-panel .error { color: #b3001b; }
/* Half a phone is too narrow for the code; the lobby takes the whole screen there. */
@media (max-width: 700px) { .squad-panel { position: fixed; } .squad-panel .code { font-size: 40px; } }

/* Polish: easing on every press, keyboard focus rings, balanced lines, gentle entrances. */
.primary, .secondary, .provider, .choices button, .round, .more, .controls .next, .link {
  transition-property: transform, box-shadow, background-color, color, opacity; transition-duration: 150ms; transition-timing-function: ease-out; }
.round:not(:disabled):active, .choices button:active { transform: scale(0.94); }
.onboard :is(button, a):focus-visible, .squad-panel :is(button, a):focus-visible, .check input:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.call :is(button, a):focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.logo, .title, .tagline, .hello, .fine, .overlay p, .squad-panel h2, .squad-panel p, .toast { text-wrap: balance; }
.rules li, .check span, .doc p, .doc li { text-wrap: pretty; }
.online { font-variant-numeric: tabular-nums; }

/* translate, not transform, so it composes with elements already positioned by transform. */
@keyframes rise { from { opacity: 0; translate: 0 12px; } }
.onboard .card, .squad-panel > div, .toast { animation: rise 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.toast { animation-duration: 0.2s; }

/* In the squad lobby there is no one to skip, and on phones the lobby fills the screen, so the
   dark glass over yellow turns muddy: solid ink there instead. */
.call:has(#squad-panel:not([hidden])) .next { visibility: hidden; }
@media (max-width: 700px) {
  .call:has(#squad-panel:not([hidden])) :is(.top, .controls) { background: none; }
  .call:has(#squad-panel:not([hidden])) :is(.pill, .round) { background: var(--ink); color: #fff; }
}

@media (prefers-reduced-motion: reduce) {
  .onboard .card, .squad-panel > div, .toast, .more.wanted, .messages li { animation: none; }
  #theirs { transition: none; }
}
