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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0a3a;
  font-family: 'Comic Sans MS', 'Trebuchet MS', system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

#game {
  display: block;
  width: 100vw;
  height: 100vh;
}

#title {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  text-align: center;
  padding:
    max(2rem, env(safe-area-inset-top))
    max(2rem, env(safe-area-inset-right))
    max(2rem, env(safe-area-inset-bottom))
    max(2rem, env(safe-area-inset-left));
  background: radial-gradient(ellipse at center, rgba(26, 24, 80, 0.4), rgba(10, 10, 58, 0.85));
  pointer-events: none;
  transition: opacity 0.8s ease, transform 0.8s ease;
}

#title.hidden {
  opacity: 0;
  transform: scale(1.05);
  pointer-events: none;
}

#title h1 {
  font-size: clamp(2.2rem, 7vw, 5rem);
  color: #ffe6f5;
  text-shadow:
    0 0 20px #ff8fcf,
    0 0 40px rgba(255, 143, 207, 0.6),
    0 0 80px rgba(255, 230, 168, 0.3);
  margin-bottom: 1.5rem;
  animation: float 4s ease-in-out infinite;
}

#title p {
  font-size: clamp(1rem, 2.2vw, 1.5rem);
  margin: 0.4rem;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

#title .key {
  background: rgba(255, 230, 168, 0.2);
  padding: 0.1em 0.5em;
  border-radius: 0.4em;
  border: 2px solid #ffe6a8;
  color: #ffe6a8;
  font-weight: bold;
}

#title .hint {
  margin-top: 2.5rem;
  font-size: clamp(1rem, 2vw, 1.3rem);
  color: #ffe6a8;
  animation: pulse 1.6s ease-in-out infinite;
}

#back {
  position: fixed;
  top: max(0.8rem, env(safe-area-inset-top));
  left: max(0.8rem, env(safe-area-inset-left));
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.55rem 0.95rem 0.55rem 0.7rem;
  border-radius: 999px;
  background: rgba(26, 24, 80, 0.55);
  color: #ffe6f5;
  text-decoration: none;
  font-family: inherit;
  font-weight: bold;
  font-size: 1rem;
  border: 2px solid rgba(255, 230, 168, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  z-index: 20;
  transition: transform 0.15s ease, background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
#back:hover, #back:active {
  transform: scale(1.05);
  background: rgba(40, 30, 100, 0.7);
}
#back:active { transform: scale(0.96); }

#hud {
  position: fixed;
  top: max(0.8rem, env(safe-area-inset-top));
  right: max(0.8rem, env(safe-area-inset-right));
  text-align: right;
  color: #ffe6f5;
  font-family: inherit;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  z-index: 15;
  pointer-events: none;
}
.hud-label {
  font-size: clamp(0.85rem, 1.4vw, 1rem);
  color: rgba(255, 230, 168, 0.85);
  letter-spacing: 0.05em;
}
.hud-value {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: bold;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
