@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700;900&family=Cormorant+Garamond:ital,wght@0,300;0,400;1,300&display=swap');

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

:root {
  --blood: #8b0000;
  --ember: #c0392b;
  --ash: #e8c4c4;
  --void: #060000;
  --deep: #0a0000;
  --sigil: #2a0808;
  --gold: #c9a84c;
}

body {
  background: var(--void);
  overflow: hidden;
  touch-action: none;
  font-family: 'Cormorant Garamond', Georgia, serif;
  color: var(--ash);
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

canvas {
  display: block;
  touch-action: none;
}

/* --- Noise / grain overlay --- */
body::after {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 50;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  background-repeat: repeat;
  opacity: 0.5;
  mix-blend-mode: overlay;
}

/* --- Vignette --- */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 49;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.6) 100%);
}

/* --- Screens --- */
.screen-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  cursor: pointer;
}

#start-screen {
  background: var(--void);
}

#game-over-screen {
  background: rgba(6, 0, 0, 0.97);
  display: none;
  backdrop-filter: blur(4px);
}

/* --- Start screen --- */
#start-screen h1 {
  font-family: 'Cinzel', Georgia, serif;
  font-size: clamp(32px, 8vw, 72px);
  font-weight: 900;
  color: var(--blood);
  letter-spacing: clamp(6px, 2vw, 16px);
  text-transform: uppercase;
  margin-bottom: 8px;
  text-shadow:
    0 0 60px rgba(139, 0, 0, 0.4),
    0 0 120px rgba(139, 0, 0, 0.15);
  animation: titleReveal 2s ease-out forwards;
  opacity: 0;
}

@keyframes titleReveal {
  0% {
    opacity: 0;
    letter-spacing: clamp(20px, 5vw, 40px);
    filter: blur(8px);
  }
  100% {
    opacity: 1;
    letter-spacing: clamp(6px, 2vw, 16px);
    filter: blur(0);
  }
}

#start-screen .subtitle {
  font-family: 'Cinzel', Georgia, serif;
  font-size: clamp(15px, 3.5vw, 24px);
  font-weight: 400;
  letter-spacing: clamp(3px, 1vw, 6px);
  text-transform: lowercase;
  margin-bottom: 60px;
  background: linear-gradient(to right, transparent 0%, var(--blood) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: subtitleReveal 2.5s ease-out 0.8s forwards;
  opacity: 0;
}

@keyframes subtitleReveal {
  0% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}

#start-screen .subtitle::after {
  content: '';
  display: block;
  width: 40px;
  height: 1px;
  background: var(--blood);
  margin: 20px auto 0;
  opacity: 0.3;
}

.screen-overlay .prompt {
  font-family: 'Cinzel', Georgia, serif;
  font-size: clamp(12px, 2vw, 16px);
  font-weight: 400;
  color: var(--ember);
  letter-spacing: 5px;
  text-transform: uppercase;
  animation: breathe 3s ease-in-out infinite;
  opacity: 0;
  animation-delay: 1.5s;
  animation-fill-mode: forwards;
}

@keyframes breathe {
  0% { opacity: 0.3; text-shadow: 0 0 0 transparent; }
  50% { opacity: 0.9; text-shadow: 0 0 20px rgba(192, 57, 43, 0.3); }
  100% { opacity: 0.3; text-shadow: 0 0 0 transparent; }
}

/* --- Game over screen --- */
#game-over-screen h2 {
  font-family: 'Cinzel', Georgia, serif;
  font-size: clamp(22px, 6vw, 44px);
  font-weight: 700;
  color: var(--blood);
  letter-spacing: clamp(4px, 1.5vw, 10px);
  text-transform: uppercase;
  margin-bottom: 12px;
  text-shadow: 0 0 40px rgba(139, 0, 0, 0.5);
  animation: screenReveal 0.8s ease-out forwards;
}

#game-over-screen .message {
  font-family: 'Cinzel', Georgia, serif;
  font-size: clamp(14px, 3vw, 22px);
  font-weight: 400;
  color: var(--blood);
  letter-spacing: clamp(3px, 1vw, 6px);
  margin-bottom: 50px;
  text-align: center;
  text-shadow: 0 0 30px rgba(139, 0, 0, 0.3);
  padding: 0 30px;
  animation: screenReveal 1s ease-out 0.3s forwards;
  opacity: 0;
}

#game-over-screen .prompt {
  animation-delay: 0.8s;
}

@keyframes screenReveal {
  0% { opacity: 0; transform: scale(0.95); filter: blur(4px); }
  100% { opacity: 1; transform: scale(1); filter: blur(0); }
}

/* --- End screen --- */
#end-screen {
  background: var(--void);
  display: none;
}

#end-screen h2 {
  font-family: 'Cinzel', Georgia, serif;
  font-size: clamp(18px, 5vw, 36px);
  font-weight: 700;
  color: var(--blood);
  letter-spacing: clamp(4px, 1.5vw, 12px);
  text-transform: uppercase;
  text-align: center;
  margin-bottom: 30px;
  text-shadow: 0 0 40px rgba(139, 0, 0, 0.4);
  animation: screenReveal 2s ease-out forwards;
  opacity: 0;
}

.end-timer {
  font-family: 'Cinzel', Georgia, serif;
  font-size: clamp(16px, 3.5vw, 28px);
  font-weight: 400;
  color: var(--blood);
  letter-spacing: clamp(3px, 1vw, 8px);
  margin-bottom: 40px;
  text-shadow: 0 0 30px rgba(139, 0, 0, 0.3);
  animation: screenReveal 2s ease-out 1s forwards;
  opacity: 0;
}

.end-links {
  display: flex;
  gap: 40px;
  animation: screenReveal 2s ease-out 2s forwards;
  opacity: 0;
}

.end-links a {
  color: var(--blood);
  transition: color 0.3s, transform 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.end-links a:hover {
  color: var(--ember);
  transform: scale(1.15);
}

/* --- Dev panel --- */
#dev-panel {
  position: fixed;
  bottom: 12px;
  right: 12px;
  z-index: 200;
  display: none;
  gap: 4px;
  opacity: 0.9;
}

#dev-panel.visible {
  display: flex;
}

#dev-panel select,
#dev-panel button {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 11px;
  background: rgba(20, 0, 0, 0.8);
  color: #8b4040;
  border: 1px solid #3a0a0a;
  padding: 4px 8px;
  cursor: pointer;
  letter-spacing: 1px;
}

#dev-panel button:hover {
  background: rgba(60, 0, 0, 0.9);
  color: #c0392b;
}

/* Dev panel hot zone */
#dev-hotzone {
  position: fixed;
  bottom: 0;
  right: 0;
  width: 60px;
  height: 60px;
  z-index: 199;
}
