:root {
  --bg: #100716;
  --ink: #fff8ff;
  --muted: #cdbde6;
  --glow: #9f7cff;
  --hot: #ff315a;
  --good: #4cffb3;
  --warn: #ffd166;
  --gentle: #82fff0;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-text-size-adjust: 100%;
}

body {
  position: fixed;
  inset: 0;
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(circle at 50% 16%, rgba(151, 94, 255, 0.34), transparent 34%),
    radial-gradient(circle at 12% 84%, rgba(255, 49, 90, 0.16), transparent 26%),
    linear-gradient(180deg, #1a0b26 0%, var(--bg) 52%, #060309 100%);
}

button,
canvas,
main,
section {
  touch-action: none;
}

#app {
  width: 100%;
  height: 100%;
  min-height: 100svh;
  padding:
    max(14px, env(safe-area-inset-top))
    max(14px, env(safe-area-inset-right))
    max(14px, env(safe-area-inset-bottom))
    max(14px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: center;
}

.phone-shell {
  position: relative;
  width: min(100%, 520px);
  height: min(100%, 820px);
  display: grid;
  grid-template-rows: auto minmax(320px, 1fr) auto;
  gap: clamp(10px, 2.4svh, 20px);
}

.status {
  position: fixed;
  z-index: 5;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(11, 5, 18, 0.58);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  backdrop-filter: blur(12px);
}

.status__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 12px var(--warn);
}

.status--connected .status__dot {
  background: var(--good);
  box-shadow: 0 0 14px var(--good);
}

.status--reconnecting .status__dot {
  animation: pulse 0.9s ease-in-out infinite;
}

.hero {
  text-align: center;
  padding-top: clamp(22px, 5svh, 48px);
}

h1 {
  margin: 0;
  font-size: clamp(2.25rem, 10vw, 4.6rem);
  line-height: 0.95;
  text-wrap: balance;
  text-shadow: 0 0 22px rgba(159, 124, 255, 0.7);
}

.instructions {
  width: min(28rem, 92%);
  margin: 12px auto 0;
  color: var(--muted);
  font-size: clamp(1rem, 4.3vw, 1.25rem);
  font-weight: 700;
}

.experience-card {
  width: min(100%, 470px);
  justify-self: center;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 24px;
  background: rgba(8, 3, 14, 0.56);
  box-shadow: inset 0 0 26px rgba(159, 124, 255, 0.1);
  backdrop-filter: blur(14px);
}

.experience-card__top {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: center;
}

.experience-card__label {
  color: #f7edff;
  font-size: 0.86rem;
  font-weight: 1000;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

.experience-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
}

.experience-toggle__button {
  min-height: 48px;
  border: 0;
  border-radius: 14px;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: clamp(0.92rem, 3.7vw, 1rem);
  font-weight: 1000;
}

.experience-toggle__button[aria-pressed="true"] {
  color: #14061c;
  background: linear-gradient(135deg, #fff7c2, var(--gentle) 52%, #ff9ac3);
  box-shadow:
    0 0 18px rgba(130, 255, 240, 0.34),
    inset 0 0 0 1px rgba(255, 255, 255, 0.44);
}

.experience-toggle__button:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.experience-hint {
  margin: 7px 4px 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
}

.ghost-pad {
  position: relative;
  width: min(100%, 470px);
  height: 100%;
  min-height: 320px;
  justify-self: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: clamp(28px, 9vw, 46px);
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.13), transparent 38%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.025));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    0 26px 60px rgba(0, 0, 0, 0.38);
}

.ghost-pad::before,
.ghost-pad::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
}

.ghost-pad::before {
  inset: 11% 8% auto;
  height: 38%;
  background: radial-gradient(circle, rgba(165, 127, 255, 0.26), transparent 70%);
  filter: blur(8px);
}

.ghost-pad::after {
  width: 210px;
  height: 52px;
  left: 50%;
  bottom: 8%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.36), transparent 70%);
}

#ghostCanvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.boo {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: grid;
  place-items: center;
  padding-bottom: 8%;
  opacity: 0;
  transform: scale(0.72) rotate(-6deg);
  color: #fff;
  font-size: clamp(3.5rem, 20vw, 7.5rem);
  font-weight: 1000;
  letter-spacing: -0.08em;
  text-align: center;
  text-shadow:
    0 0 8px #fff,
    0 0 26px var(--hot),
    0 0 54px #ff0000;
  pointer-events: none;
}

.boo.show {
  animation: boo-pop 1.35s cubic-bezier(0.17, 0.89, 0.23, 1.24) both;
}

#flash {
  position: fixed;
  z-index: 10;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  mix-blend-mode: screen;
}

body.is-scary-scare #flash {
  background: radial-gradient(circle, rgba(255, 255, 255, 0.56), rgba(255, 31, 66, 0.88) 42%, rgba(105, 0, 18, 0.94));
  animation: scare-flash 1.15s ease-out both;
}

body.is-gentle-scare #flash {
  background: radial-gradient(circle, rgba(255, 255, 255, 0.3), rgba(130, 255, 240, 0.28) 48%, rgba(159, 124, 255, 0.24));
  animation: gentle-flash 0.82s ease-out both;
}

body.is-scary-scare .ghost-pad {
  animation: shake 0.44s linear 3;
}

body.is-gentle-scare .ghost-pad {
  animation: gentle-pulse 0.9s ease-out both;
}

body.is-gentle-scare .boo {
  color: #fffaf4;
  font-size: clamp(2.5rem, 14vw, 5rem);
  letter-spacing: -0.03em;
  text-shadow:
    0 0 10px rgba(255, 255, 255, 0.85),
    0 0 26px rgba(130, 255, 240, 0.62),
    0 0 40px rgba(255, 154, 195, 0.48);
}

body.is-gentle-scare .boo.show {
  animation: gentle-boo-pop 1.05s cubic-bezier(0.16, 0.82, 0.28, 1.08) both;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(0.78);
    opacity: 0.55;
  }
  50% {
    transform: scale(1.15);
    opacity: 1;
  }
}

@keyframes boo-pop {
  0% {
    opacity: 0;
    transform: scale(0.5) rotate(-10deg);
  }
  18%,
  72% {
    opacity: 1;
    transform: scale(1.03) rotate(2deg);
  }
  100% {
    opacity: 0;
    transform: scale(1.22) rotate(6deg);
  }
}

@keyframes scare-flash {
  0% {
    opacity: 0;
  }
  8% {
    opacity: 0.95;
  }
  22% {
    opacity: 0.18;
  }
  38% {
    opacity: 0.7;
  }
  100% {
    opacity: 0;
  }
}

@keyframes gentle-flash {
  0% {
    opacity: 0;
  }
  16% {
    opacity: 0.42;
  }
  100% {
    opacity: 0;
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  25% {
    transform: translate3d(-5px, 3px, 0) rotate(-1deg);
  }
  50% {
    transform: translate3d(5px, -2px, 0) rotate(1deg);
  }
  75% {
    transform: translate3d(-3px, -4px, 0) rotate(-0.6deg);
  }
}

@keyframes gentle-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  35% {
    transform: scale(1.025);
  }
}

@keyframes gentle-boo-pop {
  0% {
    opacity: 0;
    transform: scale(0.78) rotate(-2deg);
  }
  22%,
  70% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: scale(1.08) rotate(2deg);
  }
}

@media (max-height: 650px) {
  .phone-shell {
    grid-template-rows: auto minmax(240px, 1fr) auto;
    gap: 8px;
  }

  .hero {
    padding-top: 8px;
  }

  h1 {
    font-size: clamp(1.8rem, 8vw, 3.2rem);
  }

  .instructions {
    margin-top: 7px;
    font-size: 0.95rem;
  }

  .experience-card {
    padding: 8px;
  }

  .experience-toggle__button {
    min-height: 42px;
  }

  .ghost-pad {
    min-height: 240px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
