:root {
  color-scheme: light;       /* stop dark-mode from recolouring */
  --bg: #000000;
  --orb-size: min(52vmin, 340px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  background: var(--bg);              /* always black */
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Inter", sans-serif;
  color: #e5e7eb;
  overflow: hidden;
}

/* ---------------- COUNTDOWN ---------------- */

.countdown {
  position: relative;
  pointer-events: none;
}

.countdown-circle {
  position: relative;
  width: min(32vmin, 180px);
  height: min(32vmin, 180px);
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000000;
  box-shadow:
    0 0 40px rgba(15, 23, 42, 0.9),
    0 0 90px rgba(15, 23, 42, 0.9);
}

/* rotating aurora ring behind number */
.countdown-glow {
  position: absolute;
  inset: -35%;
  border-radius: inherit;
  background:
    conic-gradient(
      from 140deg,
      rgba(248, 250, 252, 0.12),
      rgba(251, 191, 36, 0.6),
      rgba(248, 113, 113, 0.7),
      rgba(244, 114, 182, 0.7),
      rgba(56, 189, 248, 0.7),
      rgba(248, 250, 252, 0.12)
    );
  filter: blur(16px);
  opacity: 0.9;
  animation: countdownGlow 9s linear infinite;
}

/* big straight number */
.countdown-number {
  position: relative;
  display: inline-block;
  font-weight: 600;
  font-size: clamp(3.8rem, 14vmin, 5.8rem);
  letter-spacing: 0.15em;
  margin-left: 0.14em;      /* subtle nudge to the right for visual centering */
  background: radial-gradient(circle at 50% 10%, #f9fafb, #fee2e2, #a5b4fc);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow:
    0 0 25px rgba(251, 191, 36, 0.45),
    0 0 55px rgba(56, 189, 248, 0.4);
  transform-origin: center;
}

/* per-tick pulse */
.countdown-number.tick {
  animation: countdownPulse 0.9s cubic-bezier(0.16, 1, 0.3, 1);
}

/* fade out whole countdown */
.countdown.fade-out {
  animation: fadeOut 0.6s ease forwards;
}

/* keyframes for countdown */

@keyframes countdownPulse {
  0% {
    transform: scale(0.6);
    filter: blur(6px);
    opacity: 0;
  }
  25% {
    transform: scale(1.18);
    filter: blur(0);
    opacity: 1;
  }
  65% {
    transform: scale(0.98);
    opacity: 0.96;
  }
  100% {
    transform: scale(1);
    opacity: 0.94;
  }
}

@keyframes countdownGlow {
  0% {
    transform: rotate(0deg) scale(1);
  }
  50% {
    transform: rotate(150deg) scale(1.05);
  }
  100% {
    transform: rotate(300deg) scale(1);
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* ---------------- GUIDANCE TEXT ---------------- */

.countdown-guidance {
  position: absolute;
  bottom: -2.4rem;
  width: 100%;
  text-align: center;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  color: #d1d5db;
  opacity: 0;
  transform: translateY(4px);
}

/* fade in + linger + fade out */
.countdown-guidance.pulse {
  animation: guidancePulse 2.6s ease-out forwards;
}

@keyframes guidancePulse {
  0% {
    opacity: 0;
    transform: translateY(6px);
  }
  25% {
    opacity: 0.8;
    transform: translateY(0px);
  }
  75% {
    opacity: 0.75;
    transform: translateY(0px);
  }
  100% {
    opacity: 0;
    transform: translateY(-2px);
  }
}

/* ---------------- ORB STAGE ---------------- */

.orb-stage {
  width: 100vw;
  height: 100vh;
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;             /* start invisible */
  visibility: hidden;
  transition: opacity 1.2s ease;
}

.orb-stage.visible {
  opacity: 1;
  visibility: visible;
}

.orb-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* overlay text inside orb */
.orb-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: rgba(249, 250, 251, 0.85);
  opacity: 0;
  pointer-events: none;
  mix-blend-mode: screen;
  text-align: center;
}

.orb-text.visible {
  animation: orbTextIn 1.4s ease-out forwards;
}

.orb-text.fade-out {
  animation: orbTextOut 1.4s ease-out forwards;
}

@keyframes orbTextIn {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  50% {
    opacity: 0.9;
    transform: translateY(0);
  }
  100% {
    opacity: 0.8;
    transform: translateY(0);
  }
}

@keyframes orbTextOut {
  0% {
    opacity: 0.8;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-6px);
  }
}

/* orbiting dot for holds (small timer orb) */
.hold-orbit {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
}

.hold-orbit.show-long,
.hold-orbit.show-short {
  opacity: 1;
}

/* fade in/out of the rotating mini-orb */
@keyframes holdFade {
  0% {
    opacity: 0;
  }
  8% {
    opacity: 1;
  }
  92% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.hold-orbit.show-long {
  animation: holdFade 60s linear forwards;
}

.hold-orbit.show-short {
  animation: holdFade 15s linear forwards;
}

.hold-orbit::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(248, 250, 251, 0.98);
  box-shadow: 0 0 10px rgba(248, 250, 251, 0.9);
}

/* 60s and 15s orbits – dot circling close to top of orb */
.hold-orbit.show-long::after {
  animation: holdOrbit 60s linear forwards;
}

.hold-orbit.show-short::after {
  animation: holdOrbit 15s linear forwards;
}

@keyframes holdOrbit {
  0% {
    transform: translate(-50%, -50%)
      rotate(0deg)
      translateY(calc(var(--orb-size) * -0.58));   /* top, snug */
  }
  100% {
    transform: translate(-50%, -50%)
      rotate(360deg)
      translateY(calc(var(--orb-size) * -0.58));
  }
}

/* ---------------- AURORA ORB ---------------- */

.aurora-orb {
  position: relative;
  width: var(--orb-size);
  height: var(--orb-size);
  border-radius: 60% 45% 55% 50% / 55% 60% 45% 50%;  /* fluid, not a perfect circle */
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 10%, #ffffff 0, rgba(255, 255, 255, 0.0) 46%),     /* highlight */
    radial-gradient(circle at 78% 15%, #e0f2fe 0, rgba(224, 242, 254, 0.0) 52%),     /* cool top */
    radial-gradient(circle at 26% 82%, #fed7aa 0, rgba(254, 215, 170, 0.0) 58%),     /* gentle sunrise */
    radial-gradient(circle at 80% 84%, #bfdbfe 0, rgba(191, 219, 254, 0.0) 55%),     /* soft blue */
    radial-gradient(circle at 50% 60%, #020617 0, #000000 72%);                      /* depth */
  background-size: 140% 140%;
  background-position:
    18% 10%,
    78% 18%,
    30% 85%,
    82% 82%,
    50% 60%;
  box-shadow:
    0 0 60px rgba(56, 189, 248, 0.7),
    0 0 120px rgba(56, 189, 248, 0.45); /* bigger exhale glow baseline */
}

/* rainbow halo overlay for happy state (7-colour glow) */
.aurora-orb::before {
  content: "";
  position: absolute;
  inset: -8%;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
}

.aurora-orb.happy::before {
  background: conic-gradient(
    #ff0000,
    #ff7f00,
    #ffff00,
    #00ff00,
    #00ffff,
    #0000ff,
    #8b00ff,
    #ff0000
  );
  filter: blur(22px);
  mix-blend-mode: screen;
  animation: happyRainbow 24s linear infinite;
}

@keyframes happyRainbow {
  0% {
    opacity: 0;
    transform: rotate(0deg);
  }
  10% {
    opacity: 0.7;
  }
  100% {
    opacity: 0.7;
    transform: rotate(360deg);
  }
}

/* breathing mode */
.aurora-orb.active {
  animation:
    orbBreathe 6s ease-in-out infinite,
    orbMorph 13s ease-in-out infinite,
    orbGlow 18s ease-in-out infinite,
    orbOuterGlow 6s ease-in-out infinite;
  /* all 4 animations running by default */
  animation-play-state: running, running, running, running;
}

/* pause at current frame (used for both exhale + inhale holds),
   but keep morph + internal glow fluid so edges still move */
.aurora-orb.paused {
  animation-play-state: paused, running, running, paused;
}

/* breathing motion – start small (exhale), then inhale */
@keyframes orbBreathe {
  0% {
    transform: scale(0.88) translateY(4px);   /* exhale (smaller, blue glow) */
  }
  45% {
    transform: scale(1.12) translateY(-6px);  /* inhale (bigger, orange glow) */
  }
  100% {
    transform: scale(0.88) translateY(4px);   /* exhale again */
  }
}

/* organic morph so it feels fluid */
@keyframes orbMorph {
  0%, 100% {
    border-radius: 60% 45% 55% 50% / 55% 60% 45% 50%;
  }
  25% {
    border-radius: 54% 60% 48% 56% / 60% 48% 54% 42%;
  }
  50% {
    border-radius: 65% 43% 52% 47% / 45% 63% 40% 55%;
  }
  75% {
    border-radius: 54% 50% 63% 45% / 52% 50% 58% 46%;
  }
}

/* slow internal flow of colours */
@keyframes orbGlow {
  0% {
    background-position:
      18% 8%,
      78% 18%,
      28% 82%,
      80% 82%,
      50% 60%;
  }
  50% {
    background-position:
      22% 12%,
      74% 20%,
      32% 86%,
      76% 78%,
      52% 62%;
  }
  100% {
    background-position:
      18% 8%,
      78% 18%,
      28% 82%,
      80% 82%,
      50% 60%;
  }
}

/* outer halo colour shift: blue (exhale) → orange (inhale) → blue */
@keyframes orbOuterGlow {
  0%,
  100% {
    box-shadow:
      0 0 60px rgba(56, 189, 248, 0.7),
      0 0 120px rgba(56, 189, 248, 0.45);
  }
  45% {
    box-shadow:
      0 0 55px rgba(251, 191, 36, 0.8),
      0 0 110px rgba(251, 191, 36, 0.55);
  }
}

/* happy state – keep exhale frame, keep morph/glow fluid, add rainbow halo */
.aurora-orb.happy {
  filter: saturate(1.12);
}

/* small screens */
@media (max-width: 600px) {
  .countdown-number {
    letter-spacing: 0.18em;
  }
}

/* ---------------- SESSION ACTIONS (RESTART / SHARE) ---------------- */

.session-actions {
  position: fixed;
  left: 50%;
  bottom: 72px;
  transform: translate(-50%, 0);
  display: flex;
  gap: 10px;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
}

.session-actions.visible {
  animation: sessionFadeIn 1.4s ease-out forwards;
  pointer-events: auto;
}

@keyframes sessionFadeIn {
  0% {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.session-btn {
  border-radius: 999px;
  border: none;
  padding: 6px 18px;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  background: #0f172a;
  color: #e5e7eb;
  cursor: pointer;
  box-shadow:
    0 0 0 1px rgba(148, 163, 184, 0.35),
    0 8px 20px rgba(0, 0, 0, 0.85);
}

.session-btn-outline {
  background: transparent;
  color: #d1fae5;
  box-shadow:
    0 0 0 1px rgba(16, 185, 129, 0.6),
    0 8px 20px rgba(0, 0, 0, 0.85);
  text-decoration: none;
}

.session-btn:active {
  transform: translateY(1px) scale(0.98);
}

@media (max-width: 480px) {
  .session-actions {
    bottom: 70px;
    gap: 8px;
  }
  .session-btn {
    padding: 6px 14px;
    font-size: 0.65rem;
  }
}

/* ---------------- PLAYER (Spotify-style, dim green bar) ---------------- */

.player {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.96);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(520px, 96vw);
  color: #e5e7eb;
  font-size: 11px;
}

.player-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 0 1 auto;
}

.player-title {
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: #e5e7eb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-sub {
  font-size: 0.68rem;
  color: #9ca3af;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-btn {
  border: none;
  outline: none;
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #020617;
  color: #e5e7eb;
  box-shadow:
    0 0 0 1px rgba(21, 128, 61, 0.35),
    0 6px 14px rgba(0, 0, 0, 0.9);
  padding: 0;
  flex: 0 0 auto;
}

.player-btn:active {
  transform: translateY(1px) scale(0.97);
}

.player-icon {
  font-size: 0.95rem;
  line-height: 1;
}

.player-progress {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  margin: 0 4px;
  min-width: 60px;
}

.player-progress-bar {
  width: 100%;
  height: 3px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.95);
  overflow: hidden;
}

.player-progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: rgba(22, 163, 74, 0.75);
  box-shadow: 0 0 10px rgba(22, 163, 74, 0.7);
}

@media (max-width: 480px) {
  .player {
    bottom: 12px;
    padding: 6px 10px;
    width: 94vw;
    gap: 8px;
  }
  .player-btn {
    width: 28px;
    height: 28px;
  }
  .player-title {
    font-size: 0.7rem;
  }
  .player-sub {
    font-size: 0.66rem;
  }
}
