:root {
  --ink: #fff8f2;
  --muted: rgba(255, 235, 225, 0.82);
  --rose: #f0a29f;
  --gold: #ffce9b;
  --panel: rgba(57, 17, 38, 0.54);
  --brightness: 0.75;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; background: #21101c; }

body {
  min-height: 100dvh;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button, input { font: inherit; }

.app {
  isolation: isolate;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  overflow: hidden;
  position: relative;
  padding: max(20px, env(safe-area-inset-top)) 22px max(18px, env(safe-area-inset-bottom));
  background:
    radial-gradient(ellipse 84% 58% at 50% 49%, rgba(168, 59, 87, 0.42), transparent 66%),
    radial-gradient(circle at 50% 37%, rgba(255, 185, 163, 0.1), transparent 30%),
    linear-gradient(155deg, #2b1024 0%, #481730 48%, #1e0c19 100%);
  transition: background 1.8s ease;
}

.app.is-on {
  background:
    radial-gradient(ellipse 96% 74% at 50% 49%, rgba(255, 189, 147, calc(0.45 * var(--brightness))), transparent 62%),
    radial-gradient(ellipse 82% 66% at 50% 47%, rgba(234, 103, 126, calc(0.46 * var(--brightness))), transparent 72%),
    radial-gradient(circle at 20% 14%, rgba(255, 184, 170, calc(0.2 * var(--brightness))), transparent 34%),
    linear-gradient(155deg, #5f203f 0%, #943e59 49%, #41132e 100%);
}

#glimmerCanvas, #reflectionCanvas, .warm-glow {
  pointer-events: none;
  position: absolute;
  inset: 0;
}

#glimmerCanvas { z-index: -3; opacity: 0.34; transition: opacity 1.2s ease; }
.app.is-on #glimmerCanvas { opacity: 0.98; }

#reflectionCanvas { z-index: -2; opacity: 0.16; transition: opacity 1.2s ease; }
.app.is-on #reflectionCanvas { opacity: 0.72; }

.warm-glow {
  z-index: -1;
  background:
    radial-gradient(circle at 50% 48%, rgba(255, 231, 193, calc(0.22 * var(--brightness))), transparent 24%),
    radial-gradient(circle at 50% 48%, rgba(255, 156, 150, calc(0.18 * var(--brightness))), transparent 47%);
  mix-blend-mode: screen;
  opacity: 0.42;
  transition: opacity 1.2s ease;
}
.app.is-on .warm-glow { opacity: 1; }

/* The ball intentionally occupies most of a phone screen and sits behind the compact controls. */
.ball-stage {
  pointer-events: none;
  position: absolute;
  z-index: 0;
  left: 50%;
  top: 48%;
  width: min(148vw, 76dvh, 680px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  filter: saturate(1.04);
  opacity: 0.8;
  transition: opacity 1.2s ease, filter 1.2s ease;
}
.app.is-on .ball-stage { filter: saturate(1.16) brightness(calc(0.82 + var(--brightness) * 0.4)); opacity: 1; }

.ball-halo {
  position: absolute;
  inset: -18%;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 236, 205, calc(0.29 * var(--brightness))) 0 11%, rgba(255, 160, 150, calc(0.22 * var(--brightness))) 27%, rgba(235, 91, 126, calc(0.1 * var(--brightness))) 47%, transparent 70%);
  filter: blur(17px);
  opacity: 0.58;
  transition: opacity 1.2s ease, transform 2.4s ease;
}
.app.is-on .ball-halo { opacity: 1; transform: scale(1.06); }

.disco-ball {
  position: absolute;
  inset: 5.8%;
  overflow: hidden;
  border-radius: 50%;
  background: #581c38;
  box-shadow:
    0 0 0 1px rgba(255, 231, 196, 0.22),
    0 0 42px 8px rgba(255, 157, 149, calc(0.21 * var(--brightness))),
    0 0 110px 25px rgba(255, 193, 150, calc(0.12 * var(--brightness))),
    inset 18px 16px 36px rgba(255, 226, 196, 0.12),
    inset -28px -30px 48px rgba(31, 5, 20, 0.48);
  transition: box-shadow 1.2s ease;
}
.app.is-on .disco-ball {
  box-shadow:
    0 0 0 1px rgba(255, 239, 204, 0.42),
    0 0 54px 13px rgba(255, 173, 151, calc(0.45 * var(--brightness))),
    0 0 138px 34px rgba(255, 205, 157, calc(0.27 * var(--brightness))),
    inset 18px 16px 36px rgba(255, 236, 211, 0.18),
    inset -28px -30px 48px rgba(31, 5, 20, 0.43);
}

#discoBallCanvas { display: block; width: 100%; height: 100%; }

.ball-glint {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(ellipse 23% 15% at 31% 25%, rgba(255, 252, 233, 0.68), rgba(255, 236, 204, 0.16) 48%, transparent 75%),
    radial-gradient(ellipse 13% 9% at 58% 18%, rgba(255, 246, 218, 0.3), transparent 73%),
    linear-gradient(137deg, rgba(255,255,255,0.1), transparent 31% 69%, rgba(71, 11, 33, 0.24));
  mix-blend-mode: screen;
  opacity: 0.48;
  transition: opacity 1.2s ease;
}
.app.is-on .ball-glint { opacity: 0.9; }

.ball-rim {
  position: absolute;
  inset: 5.1%;
  border: 1px solid rgba(255, 231, 204, 0.37);
  border-radius: 50%;
  box-shadow: inset 0 0 0 8px rgba(112, 26, 56, 0.12), inset 0 0 30px rgba(255, 224, 188, 0.13);
}

.topbar { position: relative; z-index: 2; text-align: center; }
.eyebrow { margin: 0 0 6px; color: #ffc7b9; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.21em; }
h1 { margin: 0; font-size: clamp(1.75rem, 8vw, 2.4rem); line-height: 1.1; letter-spacing: -0.045em; text-shadow: 0 2px 18px rgba(54, 5, 26, 0.45); }
.status { min-height: 1.3em; margin: 9px 0 0; color: var(--muted); font-size: 0.88rem; font-weight: 600; text-shadow: 0 1px 12px rgba(57, 9, 27, 0.72); }

/* A compact action cluster leaves the central ball almost entirely visible. */
.controls {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 9px;
  width: max-content;
  max-width: 100%;
  margin: auto 0 10px auto;
  padding: 7px;
  border: 1px solid rgba(255, 230, 213, 0.27);
  border-radius: 27px;
  background: rgba(57, 17, 38, 0.43);
  box-shadow: 0 12px 34px rgba(31, 4, 20, 0.3), inset 0 1px 0 rgba(255, 244, 236, 0.15);
  backdrop-filter: blur(15px) saturate(1.14);
  -webkit-backdrop-filter: blur(15px) saturate(1.14);
}

.power-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 166px;
  min-height: 76px;
  border: 0;
  border-radius: 20px;
  color: #4f1e34;
  background: linear-gradient(135deg, #ffe0bd, #f2a3a0 62%, #d47889);
  box-shadow: 0 8px 20px rgba(19, 3, 12, 0.25), inset 0 1px 0 rgba(255,255,255,0.7);
  cursor: pointer;
  font-size: 0.96rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  transition: transform 180ms ease, filter 300ms ease, background 700ms ease;
}
.power-button:active { transform: scale(0.98); }
.power-button:focus-visible, .intensity-dial:focus-visible { outline: 3px solid #fff2cb; outline-offset: 3px; }
.app.is-on .power-button { color: #fff8ee; background: linear-gradient(135deg, #b8536c, #682548); }
.power-icon { font-size: 1.3em; line-height: 0; }

/* The 84px dial exceeds Apple's recommended 44px touch target while staying small. */
.intensity-dial {
  --dial-progress: 68.75;
  position: relative;
  flex: 0 0 84px;
  width: 84px;
  height: 84px;
  border: 1px solid rgba(255, 230, 207, 0.31);
  border-radius: 50%;
  color: #fff5eb;
  background: radial-gradient(circle at 35% 28%, rgba(255, 230, 206, 0.2), rgba(120, 37, 64, 0.56) 55%, rgba(48, 12, 32, 0.72));
  box-shadow: 0 6px 18px rgba(31, 4, 20, 0.25), inset 0 1px 1px rgba(255,255,255,0.2);
  cursor: ns-resize;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.dial-art { display: block; width: 100%; height: 100%; overflow: visible; }
.dial-track, .dial-progress { fill: none; stroke-linecap: round; stroke-width: 7; }
.dial-track { stroke: rgba(255, 227, 206, 0.18); }
.dial-progress {
  stroke: url(#dialRoseGold);
  stroke: #ffd0a8;
  stroke-dasharray: 100;
  stroke-dashoffset: calc(100 - var(--dial-progress));
  filter: drop-shadow(0 0 3px rgba(255, 197, 158, 0.48));
  transition: stroke-dashoffset 180ms ease;
}
.dial-needle { stroke: #fff4e0; stroke-width: 2.3; stroke-linecap: round; filter: drop-shadow(0 0 2px rgba(255, 199, 161, 0.8)); transition: transform 180ms ease; }
.dial-center { fill: #ffe0bf; filter: drop-shadow(0 0 3px rgba(255, 192, 149, 0.88)); }
.dial-copy { position: absolute; inset: 0; display: grid; place-content: center; gap: 1px; text-align: center; line-height: 1; pointer-events: none; }
.dial-copy span { color: rgba(255, 235, 223, 0.82); font-size: 0.56rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.dial-copy output { color: #fff7ec; font-size: 1rem; font-weight: 800; font-variant-numeric: tabular-nums; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.safety-note { position: relative; z-index: 3; display: flex; justify-content: center; align-items: center; gap: 7px; margin: 0 auto; color: rgba(255, 234, 222, 0.9); text-align: center; font-size: 0.74rem; line-height: 1.35; text-shadow: 0 1px 9px rgba(50, 4, 24, 0.74); }
.safety-note p { margin: 0; }
.spark { color: #ffdaa1; }

@media (max-width: 360px) {
  .app { padding-inline: 16px; }
  .controls { gap: 7px; padding: 6px; }
  .power-button { width: 142px; min-height: 72px; font-size: 0.89rem; }
  .intensity-dial { flex-basis: 78px; width: 78px; height: 78px; }
}

@media (max-height: 690px) {
  .ball-stage { width: min(112vw, 78dvh, 600px); top: 48%; }
  .controls { margin-bottom: 6px; }
}

@media (min-width: 650px) {
  .ball-stage { width: min(68vw, 76dvh, 680px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
