:root {
  --ink: #3b1f2b;
  --muted: #8a6b78;
  --card: #ffffff;
  --accent: #e8457a;
  --accent-2: #ff8a65;
  --radius: 22px;
  --shadow: 0 10px 30px rgba(120, 30, 70, 0.12);
  --bg: linear-gradient(160deg, #fff1f4 0%, #ffe4ea 45%, #ffeede 100%);
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }

/* themes tint the background per game */
.page { min-height: 100vh; min-height: 100dvh; }
.t-rose  { --accent: #e8457a; background: linear-gradient(160deg, #fff1f4, #ffe0e9); }
.t-peach { --accent: #f26b3a; background: linear-gradient(160deg, #fff5ee, #ffe3d3); }
.t-lilac { --accent: #8b5cf6; background: linear-gradient(160deg, #f7f2ff, #ebe1ff); }
.t-mint  { --accent: #13a07a; background: linear-gradient(160deg, #effcf6, #d9f6ea); }
.t-sky   { --accent: #2f80ed; background: linear-gradient(160deg, #f0f7ff, #dcebff); }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.55);
}
.topbar h1 { font-size: 1.05rem; margin: 0; letter-spacing: 0.2px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.2rem;
  background: rgba(255, 255, 255, 0.8); box-shadow: var(--shadow);
}
.icon-btn.ghost { background: none; box-shadow: none; }

.screen {
  max-width: 480px; margin: 0 auto;
  padding: 18px 18px calc(32px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 16px;
}

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.lead { margin: 0; color: var(--muted); line-height: 1.5; }
.accent { color: var(--accent); font-weight: 700; }
.big-emoji { font-size: 3.2rem; line-height: 1; }

.hero, .greet { text-align: center; padding: 18px 8px 4px; }
.hero h2, .greet h2 { margin: 10px 0 6px; font-size: 1.6rem; }
.greet h2 { margin-top: 2px; }
.greet p { margin: 0; }
.heart { color: var(--accent); display: inline-block; animation: beat 1.4s infinite; }

.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px;
}
.form { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.9rem; color: var(--muted); }
input {
  width: 100%;
  border: 2px solid #f3d5df; border-radius: 14px;
  padding: 14px; font-size: 1rem; background: #fffafb; color: var(--ink);
  outline: none; transition: border-color 0.2s;
}
input:focus { border-color: var(--accent); }

.btn {
  padding: 15px 18px; border-radius: 16px; font-weight: 700; font-size: 1rem;
  transition: transform 0.12s ease, box-shadow 0.2s;
}
.btn:active, .choice:active, .mode:active, .level:active { transform: scale(0.97); }
.btn.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #ffb199));
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 35%, transparent);
}
.btn.ghost { background: rgba(255, 255, 255, 0.8); box-shadow: var(--shadow); }
.btn.wide { width: 100%; }
.row { display: flex; gap: 12px; }
.row .btn { flex: 1; }
.link { color: var(--muted); text-decoration: underline; font-size: 0.85rem; padding: 6px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  background: rgba(255, 255, 255, 0.8); border-radius: 18px; padding: 12px 6px;
  text-align: center; box-shadow: var(--shadow);
}
.stat b { display: block; font-size: 1.35rem; }
.stat span { font-size: 0.75rem; color: var(--muted); }

.modes, .levels { display: flex; flex-direction: column; gap: 12px; }
.mode, .level {
  display: flex; align-items: center; gap: 14px; text-align: left;
  padding: 16px; border-radius: var(--radius); background: var(--card);
  box-shadow: var(--shadow); border-left: 6px solid var(--accent);
  transition: transform 0.12s ease;
}
.mode-emoji {
  font-size: 1.7rem; width: 50px; height: 50px; flex: none;
  display: grid; place-items: center; border-radius: 16px;
  background: color-mix(in srgb, var(--accent) 14%, white);
}
.mode-text { display: flex; flex-direction: column; gap: 3px; }
.mode-text small { color: var(--muted); line-height: 1.35; }
.foot { display: flex; justify-content: center; gap: 18px; }

.lvl-light   { --accent: #f2a23a; }
.lvl-deeper  { --accent: #7c5cf6; }
.lvl-deepest { --accent: #e8457a; }

.chip {
  align-self: flex-start;
  display: inline-block; padding: 6px 12px; border-radius: 99px;
  font-size: 0.78rem; font-weight: 700;
  background: color-mix(in srgb, var(--accent) 14%, white); color: var(--accent);
}
.q-card { display: flex; flex-direction: column; gap: 14px; min-height: 220px; justify-content: center; }
.q-card.lvl-light, .q-card.lvl-deeper, .q-card.lvl-deepest { border-top: 6px solid var(--accent); }
.who { margin: 0; color: var(--muted); font-weight: 600; }
.question { font-size: 1.45rem; font-weight: 700; line-height: 1.35; margin: 0; }
.small-q { font-size: 1.1rem; }
.q-card form, form.q-card { gap: 14px; }

.choices { display: flex; flex-direction: column; gap: 12px; }
.choices.three { flex-direction: row; }
.choices.three .choice { flex: 1; padding: 16px 6px; font-size: 0.95rem; }
.choice {
  padding: 20px; border-radius: 18px; background: var(--card);
  box-shadow: var(--shadow); font-weight: 700; font-size: 1.1rem;
  border: 2px solid transparent; transition: transform 0.12s, border-color 0.2s;
}
.choice:hover { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }

.handoff {
  text-align: center; padding: 40px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.handoff p { margin: 0; }
.handoff-name { font-size: 2.2rem; margin: 4px 0 6px; color: var(--accent); }
.handoff .btn { margin-top: 22px; width: 100%; }

.banner { text-align: center; padding: 8px 0 0; }
.banner h2 { margin: 8px 0 0; font-size: 1.5rem; }
.banner.yes .big-emoji { animation: beat 1.2s infinite; }

.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pick {
  background: var(--card); border-radius: 18px; padding: 16px 12px;
  box-shadow: var(--shadow); text-align: center;
  display: flex; flex-direction: column; gap: 6px; justify-content: center;
}
.q-card .pick { box-shadow: none; background: color-mix(in srgb, var(--accent) 8%, white); }
.pick small { color: var(--muted); font-weight: 600; }
.pick b { font-size: 1.05rem; word-break: break-word; }
.pick .score { font-size: 2rem; color: var(--accent); }
.hint {
  margin: 0; padding: 14px 16px; border-radius: 16px;
  background: rgba(255, 255, 255, 0.7); line-height: 1.45;
}

.progress { height: 8px; background: rgba(255, 255, 255, 0.8); border-radius: 99px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.3s; }

.result h3 { margin: 12px 0 14px; font-size: 1.25rem; }
.barrow { display: grid; grid-template-columns: 1fr 90px; gap: 10px; align-items: center; margin: 8px 0; font-size: 0.85rem; }
.meter { height: 10px; border-radius: 99px; background: #f6e3ea; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.tip { margin: 14px 0 0; line-height: 1.45; font-size: 0.92rem; }

.pop { animation: pop 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.3); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes beat { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.18); } 30% { transform: scale(1); } }

.float-heart {
  position: fixed; bottom: 10vh; font-size: 1.8rem; pointer-events: none; z-index: 50;
  animation: rise 1.4s ease-out forwards;
}
@keyframes rise { to { transform: translateY(-60vh) rotate(20deg); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- two-phone mode ---------- */
.online-card {
  display: flex; align-items: center; gap: 14px; text-align: left; width: 100%;
  padding: 16px; border-radius: var(--radius); color: #fff;
  background: linear-gradient(135deg, #e8457a, #ff8a65);
  box-shadow: 0 10px 24px rgba(232, 69, 122, 0.3);
  transition: transform 0.12s ease;
}
.online-card:active { transform: scale(0.97); }
.online-card .mode-emoji { background: rgba(255, 255, 255, 0.25); }
.online-card small { color: rgba(255, 255, 255, 0.9); }

.presence { display: flex; gap: 4px; min-width: 40px; justify-content: flex-end; }
.avatar {
  position: relative; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; font-style: normal; font-weight: 700; font-size: 0.8rem;
  background: #fff; color: var(--muted); box-shadow: var(--shadow); opacity: 0.55;
}
.avatar.me { color: var(--accent); }
.avatar.on { opacity: 1; }
.avatar.on::after {
  content: ""; position: absolute; right: -1px; bottom: -1px; width: 9px; height: 9px;
  border-radius: 50%; background: #22c55e; border: 2px solid #fff;
}

.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.8rem; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: #f0d3dd; }
.code-input { text-transform: uppercase; letter-spacing: 0.4em; text-align: center; font-weight: 700; font-size: 1.3rem; }
.room-code {
  font-size: 3rem; font-weight: 800; letter-spacing: 0.25em; color: var(--accent);
  margin: 4px 0 10px; padding-left: 0.25em;
}
.link-box { font-size: 0.85rem; color: var(--muted); text-align: center; }

.waiting { text-align: center; color: var(--muted); font-weight: 600; margin: 8px 0; }
.dots::after { content: ""; animation: dots 1.4s steps(4, end) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
.answered { margin: 0; color: #13a07a; font-weight: 700; font-size: 0.9rem; }
.pick.mine { box-shadow: none; background: color-mix(in srgb, var(--accent) 8%, white); }
.choice:disabled { opacity: 0.6; }

/* re-renders of the same screen shouldn't replay the entry animation */
.calm .pop { animation: none; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: 90vw; padding: 12px 18px; border-radius: 14px; z-index: 60;
  background: var(--ink); color: #fff; font-weight: 600; font-size: 0.9rem; text-align: center;
  box-shadow: var(--shadow); animation: pop 0.25s ease-out;
}
body.offline::before {
  content: "Reconnecting…"; position: fixed; top: 0; left: 0; right: 0; z-index: 70;
  padding: 6px; text-align: center; font-size: 0.8rem; font-weight: 700;
  background: #f59e0b; color: #fff;
}

/* ---------- install as app ---------- */
.install-slot:empty { display: none; }
.install-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 18px; background: var(--card); box-shadow: var(--shadow);
}
.install-card img { border-radius: 12px; flex: none; }
.install-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.install-text small { color: var(--muted); line-height: 1.35; }
.install-actions { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.small-btn { padding: 9px 16px; font-size: 0.9rem; border-radius: 12px; }

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(59, 31, 43, 0.45);
}
.sheet {
  width: 100%; max-width: 480px; background: #fff; color: var(--ink);
  border-radius: 24px 24px 0 0; padding: 24px 22px calc(24px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center;
}
.sheet h2 { margin: 0; font-size: 1.3rem; }
.sheet-icon { border-radius: 16px; box-shadow: var(--shadow); }
.steps { list-style: none; padding: 0; margin: 4px 0; display: flex; flex-direction: column; gap: 12px; text-align: left; width: 100%; }
.steps li { display: flex; align-items: center; gap: 12px; line-height: 1.4; }
.step-n {
  flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 14%, white); color: var(--accent); font-weight: 800;
}
.ios-share { display: inline-block; padding: 0 4px; border: 1.5px solid currentColor; border-radius: 5px; font-size: 0.8rem; color: #2f80ed; }

/* installed app: a touch more breathing room under the status bar */
@media (display-mode: standalone) {
  .topbar { padding-top: max(16px, env(safe-area-inset-top)); }
}
