@import url('https://fonts.googleapis.com/css2?family=Creepster&family=Orbitron:wght@400;700;900&family=Press+Start+2P&display=swap');
* { margin: 0; padding: 0; box-sizing: border-box; }
html {
  width: 100%;
  height: 100%;
  overflow: hidden;
}
body {
  background: #f7e4c4;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100vw;
  height: 100vh;
  font-family: 'Orbitron', monospace;
}
/* #wrap is a fixed logical 900x650 box.
   Scaling to viewport is handled entirely by JS transform:scale().
   Do not use flex: 1 or max-width here — that fights Phaser's inline styles. */
#wrap {
  position: relative;
  width: 900px;
  height: 650px;
  flex-shrink: 0;
  overflow: hidden;
  transform-origin: center center;
}
/* Do NOT set width/height on canvas via CSS.
   Phaser stamps inline style.width/style.height = "900px" after init,
   which would override CSS rules and cause a no-op fight.
   Visual sizing of the canvas is controlled by #wrap's transform scale. */
canvas {
  display: block;
  image-rendering: crisp-edges;
}
/* Apply the tomato border and warm glow to #game only (not bloom, which is overlaid). */
#game {
  border: 3px solid #e63946;
  box-shadow: 0 0 60px rgba(230,57,70,0.45), 0 0 120px rgba(255,209,102,0.25), inset 0 0 30px rgba(255,209,102,0.12);
}
#bloom { position: absolute; top: 0; left: 0; pointer-events: none; mix-blend-mode: screen; opacity: 0.6; }
#ui-overlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}

/* ===== TITLE SCREEN ===== */
#title-screen, #death-screen { pointer-events: auto; text-align: center; color: #e63946; z-index: 100; }
#title-screen {
  background: radial-gradient(ellipse at center, rgba(255,240,200,0.55) 0%, rgba(247,228,196,0.85) 100%);
  padding: 60px;
  border: 2px solid #e63946;
  box-shadow: 0 0 40px rgba(230,57,70,0.28), inset 0 0 20px rgba(255,209,102,0.18);
}
#title-screen h1 {
  font-family: 'Creepster', cursive;
  font-size: 96px;
  letter-spacing: 12px;
  animation: flicker 3s infinite;
  margin-bottom: 5px;
  /* Cartoon pizza-sign: tomato-red core with yellow outline halo */
  text-shadow: 0 0 0 #ffd166, 2px 2px 0 #ffd166, -2px 2px 0 #ffd166, 2px -2px 0 #ffd166, -2px -2px 0 #ffd166, 0 0 30px rgba(230,57,70,0.7), 0 0 60px rgba(255,209,102,0.5), 0 4px 15px rgba(122,58,26,0.5);
  filter: drop-shadow(0 0 8px rgba(230,57,70,0.45));
}
#title-screen .subtitle {
  font-size: 12px;
  color: #7a3a1a;
  margin-bottom: 50px;
  letter-spacing: 3px;
  text-shadow: 0 0 15px rgba(255,209,102,0.6);
  font-weight: 700;
}
#title-screen .start-prompt {
  font-size: 13px;
  color: #2a9d8f;
  animation: pulse 1.2s infinite;
  text-shadow: 0 0 15px rgba(42,157,143,0.65);
  letter-spacing: 2px;
  margin-top: 30px;
}

/* ===== DEATH SCREEN ===== */
#death-screen {
  display: none;
  background: radial-gradient(ellipse at center, rgba(255,240,200,0.6) 0%, rgba(247,228,196,0.9) 100%);
  padding: 50px 80px;
  border: 3px solid #e63946;
  box-shadow: 0 0 50px rgba(230,57,70,0.35), inset 0 0 30px rgba(255,209,102,0.2);
}
#death-screen h2 {
  font-family: 'Creepster', cursive;
  font-size: 72px;
  animation: shake 0.2s infinite;
  margin-bottom: 25px;
  color: #e63946;
  text-shadow: 0 0 0 #ffd166, 2px 2px 0 #ffd166, -2px 2px 0 #ffd166, 2px -2px 0 #ffd166, -2px -2px 0 #ffd166, 0 0 40px rgba(230,57,70,0.7), 0 0 80px rgba(255,209,102,0.4);
  letter-spacing: 8px;
}
#death-screen .stats {
  font-size: 11px;
  color: #7a3a1a;
  line-height: 2.6;
  margin-bottom: 35px;
  background: rgba(255,245,220,0.5);
  padding: 20px 30px;
  border-left: 3px solid #2a9d8f;
  text-shadow: 0 0 10px rgba(255,209,102,0.5);
  letter-spacing: 1px;
}
#death-screen .stats div { display: flex; justify-content: space-between; min-width: 350px; }
#death-screen .stats span { color: #e63946; font-weight: 700; }
#death-screen .restart-prompt {
  font-size: 12px;
  color: #2a9d8f;
  animation: pulse 1.2s infinite;
  text-shadow: 0 0 12px rgba(42,157,143,0.65);
  letter-spacing: 2px;
}

/* ===== HUD ===== */
#hud-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  align-items: flex-start;
  justify-content: space-between;
  padding: 12px;
  font-size: 11px;
  font-weight: 700;
  z-index: 50;
  letter-spacing: 1px;
}
.hud-panel {
  background: rgba(255,245,220,0.45);
  border: 1px solid #e63946;
  padding: 8px 15px;
  box-shadow: 0 0 15px rgba(230,57,70,0.18);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.hud-label { color: #7a3a1a; font-size: 8px; letter-spacing: 1px; }
.hud-value { color: #e63946; text-shadow: 0 0 8px rgba(230,57,70,0.45); font-size: 12px; }
.hud-panel.souls .hud-value { color: #c8102e; text-shadow: 0 0 8px rgba(255,180,100,0.5); }
.hud-panel.speed .hud-value { color: #2a9d8f; text-shadow: 0 0 8px rgba(42,157,143,0.45); }
.hud-panel.combo { position: absolute; bottom: 12px; left: 12px; padding: 10px 20px; pointer-events: none; }
.hud-panel.combo .hud-value { color: #e63946; font-size: 14px; text-shadow: 0 0 12px rgba(230,57,70,0.7); }

/* ===== ANIMATIONS ===== */
@keyframes flicker {
  0%,92%,100%{opacity:1}
  93%{opacity:0.2}
  94%{opacity:0.9}
  95%{opacity:0.15}
  96%{opacity:0.95}
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-3px) rotate(-0.5deg)} 75%{transform:translateX(3px) rotate(0.5deg)} }
@keyframes glow {
  0%,100%{text-shadow: 0 0 10px rgba(255,102,0,0.5), 0 0 20px rgba(255,102,0,0.2)}
  50%{text-shadow: 0 0 20px rgba(255,102,0,0.9), 0 0 40px rgba(255,102,0,0.4)}
}
.combo-active { animation: glow 0.6s infinite !important; }

/* Combo milestone burst: replaces glow briefly, then returns to glow.
   Class is added/removed via JS each time a milestone is crossed. */
@keyframes combo-milestone-burst {
  0%   { transform: scale(1);    box-shadow: 0 0 15px rgba(255,200,0,0.3); }
  30%  { transform: scale(1.18); box-shadow: 0 0 40px rgba(255,200,0,0.9), 0 0 80px rgba(255,200,0,0.4); }
  60%  { transform: scale(1.06); box-shadow: 0 0 20px rgba(255,200,0,0.6); }
  100% { transform: scale(1);    box-shadow: 0 0 15px rgba(255,102,0,0.2); }
}
.combo-milestone {
  animation: combo-milestone-burst 0.4s ease-out forwards !important;
}
