*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0a0a0f;
  --text: #f4f0eb;
  --text-muted: rgba(244, 240, 235, 0.55);
  --accent: #c9a87c;
  --accent-glow: rgba(201, 168, 124, 0.35);
  --font-display: "Cormorant Garamond", Georgia, serif;
  --font-body: "Outfit", system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

html,
body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 300;
  user-select: none;
  -webkit-user-select: none;
  caret-color: transparent;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Aurora background */
.aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.aurora__blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.45;
  animation: drift 18s ease-in-out infinite alternate;
}

.aurora__blob--1 {
  width: 55vw;
  height: 55vw;
  top: -15%;
  left: -10%;
  background: radial-gradient(circle, #2a1f3d 0%, transparent 70%);
}

.aurora__blob--2 {
  width: 45vw;
  height: 45vw;
  bottom: -20%;
  right: -10%;
  background: radial-gradient(circle, #1a2a35 0%, transparent 70%);
  animation-delay: -6s;
}

.aurora__blob--3 {
  width: 35vw;
  height: 35vw;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(201, 168, 124, 0.25) 0%, transparent 70%);
  animation-delay: -12s;
}

@keyframes drift {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(4%, 6%) scale(1.08); }
}

/* Game canvas */
#game {
  position: fixed;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* Overlay UI */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: opacity 0.4s ease;
  padding:
    calc(1rem + var(--safe-top))
    calc(1rem + var(--safe-right))
    calc(4.5rem + var(--safe-bottom))
    calc(1rem + var(--safe-left));
}

.overlay.is-hidden {
  opacity: 0;
}

.overlay.is-gameover {
  opacity: 1;
}

.hero {
  text-align: center;
  padding: 1rem;
  max-width: 42rem;
  width: 100%;
}

.eyebrow {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.5rem;
  animation: fadeUp 1s ease 0.3s both;
}

.title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.5rem, 11vw, 6.5rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
  word-break: break-word;
}

.title__word {
  display: inline-block;
  animation: fadeUp 1s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.title__word:first-child {
  animation-delay: 0.5s;
}

.title__word--accent {
  font-style: italic;
  color: var(--accent);
  text-shadow: 0 0 60px var(--accent-glow);
  animation-delay: 0.75s;
}

.subtitle {
  font-size: clamp(0.95rem, 2.8vw, 1.15rem);
  color: var(--text-muted);
  line-height: 1.6;
  animation: fadeUp 1s ease 1.1s both;
  padding: 0 0.5rem;
}

.divider {
  width: 3rem;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  margin: 1.75rem auto;
  animation: fadeUp 1s ease 1.3s both, shimmer 3s ease-in-out 2s infinite;
}

@keyframes shimmer {
  0%, 100% { opacity: 0.4; transform: scaleX(1); }
  50% { opacity: 1; transform: scaleX(1.3); }
}

.hint {
  font-size: clamp(0.7rem, 2.5vw, 0.85rem);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  animation: fadeUp 1s ease 1.5s both;
  padding: 0 0.5rem;
  line-height: 1.5;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(1.2rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* HUD */
.hud {
  position: fixed;
  top: calc(1rem + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  pointer-events: none;
}

.hud__score {
  font-family: var(--font-display);
  font-size: clamp(2rem, 8vw, 2.5rem);
  color: var(--text);
  text-shadow: 0 0 30px var(--accent-glow);
  line-height: 1;
}

.hud__best {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Sound toggle */
.sound-btn {
  position: fixed;
  top: calc(1rem + var(--safe-top));
  right: calc(1rem + var(--safe-right));
  z-index: 4;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid rgba(201, 168, 124, 0.25);
  border-radius: 50%;
  background: rgba(10, 10, 15, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--accent);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.sound-btn:active {
  transform: scale(0.94);
}

.sound-btn__icon {
  width: 1.15rem;
  height: 1.15rem;
}

.sound-btn__icon--off {
  display: none;
}

.sound-btn.is-muted .sound-btn__icon--on {
  display: none;
}

.sound-btn.is-muted .sound-btn__icon--off {
  display: block;
}

/* Footer */
.footer {
  position: fixed;
  bottom: calc(1rem + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  pointer-events: none;
  animation: fadeUp 1s ease 1.8s both;
  max-width: calc(100% - 2rem);
  text-align: center;
}

.footer__domain {
  color: var(--accent);
  opacity: 0.7;
  word-break: break-all;
}

/* Mobile */
@media (max-width: 480px) {
  .eyebrow {
    font-size: 0.62rem;
    letter-spacing: 0.22em;
    margin-bottom: 1rem;
  }

  .title {
    font-size: clamp(2.2rem, 13vw, 3.5rem);
    margin-bottom: 0.75rem;
  }

  .divider {
    margin: 1.25rem auto;
  }

  .overlay.is-gameover .title {
    font-size: clamp(1.8rem, 10vw, 3rem);
  }

  .sound-btn {
    width: 2.5rem;
    height: 2.5rem;
  }
}

/* Short screens */
@media (max-height: 600px) {
  .hero {
    padding: 0.5rem;
  }

  .eyebrow {
    margin-bottom: 0.75rem;
  }

  .title {
    font-size: clamp(2rem, 9vh, 3.5rem);
    margin-bottom: 0.5rem;
  }

  .divider {
    margin: 1rem auto;
  }

  .footer {
    font-size: 0.62rem;
    bottom: calc(0.5rem + var(--safe-bottom));
  }
}

/* Landscape phone */
@media (max-height: 500px) and (orientation: landscape) {
  .overlay {
    align-items: flex-start;
    padding-top: calc(0.5rem + var(--safe-top));
  }

  .hero {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 1.5rem;
    text-align: left;
    align-items: center;
    max-width: 56rem;
  }

  .eyebrow {
    grid-column: 1 / -1;
    margin-bottom: 0;
  }

  .title {
    margin-bottom: 0;
    font-size: clamp(2rem, 10vh, 3rem);
  }

  .subtitle,
  .hint {
    text-align: left;
    padding: 0;
  }

  .divider {
    display: none;
  }

  .hud {
    top: auto;
    bottom: calc(1rem + var(--safe-bottom));
    left: calc(1rem + var(--safe-left));
    transform: none;
    align-items: flex-start;
  }

  .footer {
    display: none;
  }
}

/* Coarse pointer — phones & tablets */
@media (pointer: coarse) {
  body {
    cursor: default;
  }
}
