:root {
  --bg: #0d0b12;
  --surface: #16131f;
  --surface2: #1e1a2e;
  --border: rgba(255, 255, 255, 0.07);
  --text: #e8e0f0;
  --muted: #7a6e8a;
  --pink: #e87fa0;
  --pink-dim: #b85c78;
  --pink-glow: rgba(232, 127, 160, 0.18);
  --lilac: #b39ddb;
  --lilac-dim: #7c6ba0;
  --teal: #7ecec4;
  --gold: #f0c080;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Sora", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

/* ── Starfield canvas ─────────────────────────────── */
#starfield {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* ── Ambient orbs ────────────────────────────────── */
.bg-orbs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  animation: orbDrift ease-in-out infinite;
}
.orb-1 {
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, #7c3aed 0%, transparent 70%);
  top: -120px;
  left: -80px;
  animation-duration: 18s;
}
.orb-2 {
  width: 340px;
  height: 340px;
  background: radial-gradient(circle, #e87fa0 0%, transparent 70%);
  bottom: -80px;
  right: -60px;
  animation-duration: 22s;
  animation-delay: -8s;
}
.orb-3 {
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, #0e7490 0%, transparent 70%);
  top: 40%;
  left: 60%;
  animation-duration: 26s;
  animation-delay: -14s;
}

@keyframes orbDrift {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }
  33% {
    transform: translate(30px, -20px) scale(1.05);
  }
  66% {
    transform: translate(-20px, 30px) scale(0.97);
  }
}

/* ── Card ─────────────────────────────────────────── */
.card {
  position: relative;
  z-index: 10;
  width: 90%;
  max-width: 420px;
  animation: cardIn 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.card-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px 44px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04),
    0 24px 64px rgba(0, 0, 0, 0.5),
    0 8px 24px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
  animation: cardFloat 7s ease-in-out infinite;
}

@keyframes cardFloat {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

/* ── Typography ───────────────────────────────────── */
.title {
  font-family: "Klee One", cursive;
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: -0.3px;
}

.subtitle {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 28px;
  font-weight: 300;
}

/* ── Status row ───────────────────────────────────── */
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 9px 14px;
  border-radius: 12px;
  margin-bottom: 28px;
  width: 100%;
  gap: 12px;
}

.status-label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.2px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3a3348;
  flex-shrink: 0;
  transition:
    background 0.4s,
    box-shadow 0.4s;
}
.status-dot.connected {
  background: #7ecb7e;
  box-shadow: 0 0 8px rgba(126, 203, 126, 0.7);
  animation: dotPulse 2.5s ease-in-out infinite;
}
.status-dot.error {
  background: var(--pink);
}

@keyframes dotPulse {
  0%,
  100% {
    box-shadow: 0 0 6px rgba(126, 203, 126, 0.6);
  }
  50% {
    box-shadow: 0 0 14px rgba(126, 203, 126, 1);
  }
}

.connect-btn {
  font-family: "Sora", sans-serif;
  font-weight: 600;
  font-size: 0.7rem;
  padding: 5px 12px;
  border: 1px solid var(--lilac-dim);
  border-radius: 8px;
  background: transparent;
  color: var(--lilac);
  cursor: pointer;
  letter-spacing: 0.3px;
  transition:
    background 0.2s,
    border-color 0.2s,
    color 0.2s;
  flex-shrink: 0;
}
.connect-btn:hover {
  background: rgba(179, 157, 219, 0.12);
  border-color: var(--lilac);
}

/* ── Pat button ───────────────────────────────────── */
.pat-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 28px;
}

.pat-glow {
  position: absolute;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--pink-glow) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
}

.pat-wrap:has(.pat-btn:not(:disabled)):hover .pat-glow,
.pat-btn.patting ~ .pat-glow {
  opacity: 1;
}

.pat-btn {
  font-family: "Klee One", cursive;
  font-size: 1.4rem;
  font-weight: 600;
  background: linear-gradient(145deg, #c8607c, #e87fa0, #d46880);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 140px;
  height: 140px;
  cursor: pointer;
  position: relative;
  box-shadow:
    0 0 0 1px rgba(232, 127, 160, 0.3),
    0 8px 24px rgba(232, 127, 160, 0.25),
    0 2px 8px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition:
    transform 0.12s,
    box-shadow 0.2s,
    opacity 0.3s;
  user-select: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  overflow: hidden;
}

.pat-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  filter: saturate(0.5);
}

.pat-btn:not(:disabled):hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow:
    0 0 0 1px rgba(232, 127, 160, 0.5),
    0 12px 32px rgba(232, 127, 160, 0.4),
    0 4px 12px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.pat-btn:not(:disabled):active {
  transform: translateY(2px) scale(0.95);
  box-shadow:
    0 0 0 1px rgba(232, 127, 160, 0.2),
    0 2px 8px rgba(232, 127, 160, 0.2),
    inset 0 2px 6px rgba(0, 0, 0, 0.3);
}

.pat-btn.patting {
  animation: patBounce 0.32s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes patBounce {
  0% {
    transform: scale(1) translateY(0);
  }
  25% {
    transform: scale(0.87) translateY(6px);
  }
  65% {
    transform: scale(1.08) translateY(-6px);
  }
  100% {
    transform: scale(1) translateY(0);
  }
}

.pat-emoji {
  font-size: 2rem;
  line-height: 1;
}
.pat-text {
  font-size: 0.95rem;
  letter-spacing: 0.8px;
  opacity: 0.95;
}

/* Ripple */
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: scale(0);
  animation: rippleOut 0.55s ease-out forwards;
  pointer-events: none;
}
@keyframes rippleOut {
  to {
    transform: scale(3.5);
    opacity: 0;
  }
}

/* ── Stats row ────────────────────────────────────── */
.stats-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 0;
}

.stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  transition:
    transform 0.15s,
    color 0.15s;
  font-variant-numeric: tabular-nums;
}

.stat-value.bump {
  animation: statBump 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes statBump {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.35);
  }
  100% {
    transform: scale(1);
  }
}

.stat-value.combo-active {
  color: var(--gold);
}

.stat-label {
  font-size: 0.65rem;
  color: var(--muted);
  font-weight: 400;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.stat-divider {
  width: 1px;
  height: 32px;
  background: var(--border);
  flex-shrink: 0;
}

/* ── Floating hearts ──────────────────────────────── */
.float-heart {
  position: fixed;
  pointer-events: none;
  font-size: 1.3rem;
  z-index: 100;
  animation: floatHeart 1.3s ease-out forwards;
  will-change: transform, opacity;
}
@keyframes floatHeart {
  0% {
    opacity: 1;
    transform: translateY(0) scale(0.9) rotate(-5deg);
  }
  30% {
    opacity: 1;
    transform: translateY(-40px) scale(1.1) rotate(5deg);
  }
  100% {
    opacity: 0;
    transform: translateY(-110px) scale(0.8) rotate(15deg);
  }
}

/* ── Mono online/offline pill ─────────────────────── */
.mono-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  padding: 7px 16px;
  border-radius: 99px;
  background: var(--surface2);
  border: 1px solid var(--border);
  margin-bottom: 24px;
  width: fit-content;
  align-self: center;
  transition:
    border-color 0.4s,
    color 0.4s;
  letter-spacing: 0.2px;
}
.mono-status.online {
  border-color: rgba(126, 203, 126, 0.3);
  color: #a8dba8;
}
.mono-status.offline {
  border-color: rgba(232, 127, 160, 0.2);
  color: var(--muted);
}

.mono-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
  transition:
    background 0.4s,
    box-shadow 0.4s;
}
.mono-status.online .mono-dot {
  background: #7ecb7e;
  box-shadow: 0 0 8px rgba(126, 203, 126, 0.8);
  animation: dotPulse 2.5s ease-in-out infinite;
}
.mono-status.offline .mono-dot {
  background: #4a3f5a;
}

/* ── Footer ───────────────────────────────────────── */
.footer {
  margin-top: 20px;
  font-size: 0.75rem;
  color: var(--muted);
  z-index: 10;
  position: relative;
  text-align: center;
}
.footer-link {
  color: var(--pink);
  text-decoration: none;
  font-weight: 600;
  transition: opacity 0.2s;
}
.footer-link:hover {
  opacity: 0.7;
}

/* ── Mobile polish ────────────────────────────────── */
@media (max-width: 480px) {
  .card-inner {
    padding: 28px 24px 24px;
  }
  .title {
    font-size: 1.5rem;
  }
  .pat-btn {
    width: 130px;
    height: 130px;
  }
  .pat-emoji {
    font-size: 1.8rem;
  }
  .stats-row {
    border-radius: 12px;
  }
  .stat-value {
    font-size: 1.2rem;
  }
}

/* Safe area insets for notched phones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .footer {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ── Twemoji ──────────────────────────────────────── */
img.emoji {
  height: 1em;
  width: 1em;
  vertical-align: -0.1em;
  display: inline-block;
}
