:root {
  --bg: #0a0a0a;
  --bg-warm: #0d0a08;
  --text: #e8e4df;
  --text-dim: #5a5550;
  --ember: #f5ebe0;
  --ember-glow: rgba(245, 235, 224, 0.15);
  --ember-core: #faf6f0;
  --pulse-glow: rgba(255, 248, 240, 0.08);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: 'Sora', -apple-system, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.container {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  height: 100dvh;
  padding: 2rem;
}

/* Ambient background glow */
.ambient {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: radial-gradient(
    circle at 50% 60%,
    var(--pulse-glow) 0%,
    transparent 50%
  );
  opacity: 0;
  transition: opacity 0.8s ease;
  pointer-events: none;
}

.ambient.active {
  opacity: 1;
}

.ambient.pulse {
  animation: ambientPulse 0.6s ease-out;
}

@keyframes ambientPulse {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0.3;
    transform: scale(1.1);
  }
}

/* Presence counter */
.presence {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 4rem;
  opacity: 0;
  transform: translateY(10px);
  animation: fadeIn 1s ease 0.3s forwards;
}

@keyframes fadeIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.count {
  font-size: clamp(3rem, 10vw, 5rem);
  font-weight: 300;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--text);
  transition: opacity 0.3s ease;
}

.count.disconnected {
  opacity: 0.3;
}

.label {
  font-size: 0.875rem;
  font-weight: 400;
  letter-spacing: 0.15em;
  text-transform: lowercase;
  color: var(--text-dim);
  margin-top: 0.5rem;
}

/* The hold button */
.hold-button {
  position: relative;
  width: clamp(140px, 35vw, 180px);
  height: clamp(140px, 35vw, 180px);
  border: none;
  background: transparent;
  cursor: pointer;
  outline: none;
  opacity: 0;
  transform: scale(0.9);
  animation: buttonIn 0.8s ease 0.5s forwards;
}

@keyframes buttonIn {
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.button-glow,
.button-ring,
.button-core {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Outer glow - only visible when held */
.button-glow {
  inset: -30px;
  background: radial-gradient(
    circle,
    var(--ember-glow) 0%,
    transparent 70%
  );
  opacity: 0;
  transform: scale(0.8);
}

/* Ring border */
.button-ring {
  border: 2px solid var(--text-dim);
  background: transparent;
}

/* Inner core - fills when held */
.button-core {
  inset: 8px;
  background: transparent;
  opacity: 0;
}

/* Hover state */
.hold-button:hover .button-ring {
  border-color: var(--text);
}

/* Active/pressed state */
.hold-button:active {
  transform: scale(0.96);
}

/* Held state */
.hold-button.held {
  transform: scale(1);
}

.hold-button.held .button-glow {
  opacity: 1;
  transform: scale(1);
}

.hold-button.held .button-ring {
  border-color: var(--ember);
  box-shadow:
    0 0 30px var(--ember-glow),
    inset 0 0 20px var(--ember-glow);
}

.hold-button.held .button-core {
  opacity: 1;
  background: radial-gradient(
    circle at 50% 40%,
    var(--ember-core) 0%,
    var(--ember) 50%,
    rgba(245, 235, 224, 0.8) 100%
  );
  box-shadow: 0 0 40px var(--ember-glow);
}

/* Ripple element */
.button-ripple {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--ember);
  opacity: 0;
  pointer-events: none;
}

/* Ripple animation on pulse */
.hold-button.pulse .button-ripple {
  animation: rippleOut 1s ease-out;
}

@keyframes rippleOut {
  0% {
    transform: scale(1);
    opacity: 0.6;
  }
  100% {
    transform: scale(2.5);
    opacity: 0;
  }
}

/* Screen pulse - gentle fallback for no haptics */
@keyframes screenPulse {
  0% {
    opacity: 0;
  }
  30% {
    opacity: 0.06;
  }
  100% {
    opacity: 0;
  }
}

.pulse-flash {
  position: fixed;
  inset: 0;
  background: radial-gradient(
    circle at 50% 60%,
    var(--ember) 0%,
    transparent 70%
  );
  pointer-events: none;
  opacity: 0;
  z-index: 100;
}

.pulse-flash.active {
  animation: screenPulse 0.8s ease-in-out;
}

/* Hint text */
.hint {
  position: absolute;
  bottom: 15%;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: lowercase;
  color: var(--text-dim);
  opacity: 0;
  animation: hintIn 1s ease 1.2s forwards;
  transition: opacity 0.5s ease;
}

@keyframes hintIn {
  to {
    opacity: 1;
  }
}

.hint.hidden {
  opacity: 0 !important;
}

/* Breathing animation for idle state */
@keyframes breathe {
  0%, 100% {
    transform: scale(1);
    opacity: 0.6;
  }
  50% {
    transform: scale(1.02);
    opacity: 1;
  }
}

.hold-button:not(.held) .button-ring {
  animation: breathe 4s ease-in-out infinite;
}

/* Responsive adjustments */
@media (min-width: 768px) {
  .presence {
    margin-bottom: 5rem;
  }

  .hint {
    bottom: 20%;
  }
}

/* Safe area for notched devices */
@supports (padding: env(safe-area-inset-bottom)) {
  .container {
    padding-bottom: calc(2rem + env(safe-area-inset-bottom));
  }
}
