@import url('https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@400;700&display=swap');

:root {
  --primary-color: #06f6ff;
  --secondary-color: #ff3e78;
  --bg-color: #0e0b16;
  --text-color: #e7dffb;
  --shadow-color: #a239ca;
  --button-color: #4717f6;
  --button-hover: #7e57ff;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Chakra Petch', sans-serif;
}

body {
  background: #000000;
  color: var(--text-color);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  position: relative;
}

body::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  background: none;
  z-index: -1;
}

canvas {
  display: block;
}

#container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

#container.ready #instructions {
  opacity: 1;
  transform: translateY(0);
}

#container.playing #instructions,
#container.ended #instructions {
  display: none;
}

#container.ended #results {
  background: transparent;
}

#score {
  position: absolute;
  top: 30px;
  right: 30px;
  font-size: 3em;
  font-weight: 700;
  color: var(--primary-color);
  text-shadow: 
      0 0 5px var(--primary-color),
      0 0 10px var(--primary-color),
      0 0 15px rgba(6, 246, 255, 0.5);
  z-index: 10;
  letter-spacing: 0.1em;
  animation: pulseScore 2s infinite alternate;
}

#instructions, #results {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: transparent;
  z-index: 100;
  transition: all 0.5s ease;
}

#results {
  opacity: 0;
  pointer-events: none;
  transform: translateY(50px);
}

.content {
  background: rgba(0, 0, 0, 0.8);
  border: 2px solid var(--primary-color);
  border-radius: 0;
  padding: 2.5em;
  text-align: center;
  max-width: 600px;
  width: 90%;
  box-shadow: 
      0 0 10px var(--primary-color),
      0 0 20px rgba(6, 246, 255, 0.5);
  position: relative;
  overflow: hidden;
  clip-path: polygon(
    0 0, 
    100% 0, 
    100% 85%, 
    85% 100%, 
    0 100%
  );
}

.content::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
      to bottom right,
      transparent,
      transparent,
      transparent,
      transparent,
      rgba(6, 246, 255, 0.1),
      transparent
  );
  transform: rotate(30deg);
  animation: sheen 3s infinite linear;
}

.content::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 25px;
  height: 25px;
  background: var(--secondary-color);
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
}

@keyframes sheen {
  0% {
      transform: translateX(-100%) rotate(30deg);
  }
  100% {
      transform: translateX(100%) rotate(30deg);
  }
}

h1, h2 {
  font-size: 2.5em;
  margin-bottom: 0.5em;
  color: var(--secondary-color);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  position: relative;
}

.glitch {
  position: relative;
  text-shadow: 
      0.05em 0 0 rgba(255, 62, 120, 0.75),
      -0.025em -0.05em 0 rgba(6, 246, 255, 0.75),
      0.025em 0.05em 0 rgba(162, 57, 202, 0.75);
  animation: glitch-anim 3s infinite linear alternate-reverse;
}

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.glitch::before {
  color: var(--secondary-color);
  animation: glitch-anim-1 0.8s infinite ease-in-out alternate-reverse;
}

.glitch::after {
  color: var(--primary-color);
  animation: glitch-anim-2 1.2s infinite ease-in-out alternate-reverse;
}

@keyframes glitch-anim {
  0% {
      clip-path: inset(80% 0 0 0);
  }
  20% {
      clip-path: inset(10% 0 60% 0);
  }
  40% {
      clip-path: inset(50% 0 10% 0);
  }
  60% {
      clip-path: inset(30% 0 40% 0);
  }
  80% {
      clip-path: inset(70% 0 10% 0);
  }
  100% {
      clip-path: inset(5% 0 85% 0);
  }
}

@keyframes glitch-anim-1 {
  0% {
      clip-path: inset(40% 0 60% 0);
      transform: translate(-0.04em, 0.02em);
  }
  20% {
      clip-path: inset(80% 0 20% 0);
      transform: translate(0.02em, -0.04em);
  }
  40% {
      clip-path: inset(20% 0 80% 0);
      transform: translate(-0.05em, 0.05em);
  }
  60% {
      clip-path: inset(60% 0 40% 0);
      transform: translate(0.04em, -0.02em);
  }
  80% {
      clip-path: inset(10% 0 90% 0);
      transform: translate(-0.02em, 0.05em);
  }
  100% {
      clip-path: inset(70% 0 30% 0);
      transform: translate(0.05em, -0.05em);
  }
}

@keyframes glitch-anim-2 {
  0% {
      clip-path: inset(10% 0 90% 0);
      transform: translate(0.05em, -0.025em);
  }
  20% {
      clip-path: inset(60% 0 40% 0);
      transform: translate(-0.05em, -0.025em);
  }
  40% {
      clip-path: inset(20% 0 80% 0);
      transform: translate(-0.05em, 0.025em);
  }
  60% {
      clip-path: inset(80% 0 20% 0);
      transform: translate(0.05em, 0.025em);
  }
  80% {
      clip-path: inset(30% 0 70% 0);
      transform: translate(0.05em, -0.025em);
  }
  100% {
      clip-path: inset(50% 0 50% 0);
      transform: translate(-0.05em, -0.025em);
  }
}

@keyframes pulseScore {
  0% {
      text-shadow: 
          0 0 5px var(--primary-color),
          0 0 10px var(--primary-color);
      transform: scale(1);
  }
  100% {
      text-shadow: 
          0 0 10px var(--primary-color),
          0 0 20px var(--primary-color),
          0 0 30px var(--primary-color);
      transform: scale(1.05);
  }
}

p {
  margin-bottom: 1em;
  line-height: 1.6;
  font-size: 1.1em;
  color: #e7dffb;
  text-shadow: 0 0 5px rgba(231, 223, 251, 0.3);
}

@keyframes glitch-anim2 {
  0% {
    clip-path: inset(10% 0 60% 0);
  }
  5% {
    clip-path: inset(30% 0 40% 0);
  }
  10% {
    clip-path: inset(50% 0 20% 0);
  }
  15% {
    clip-path: inset(70% 0 10% 0);
  }
  20% {
    clip-path: inset(20% 0 30% 0);
  }
  25% {
    clip-path: inset(40% 0 20% 0);
  }
  30% {
    clip-path: inset(60% 0 30% 0);
  }
  35% {
    clip-path: inset(10% 0 50% 0);
  }
  40% {
    clip-path: inset(30% 0 40% 0);
  }
  45% {
    clip-path: inset(50% 0 20% 0);
  }
  50% {
    clip-path: inset(70% 0 10% 0);
  }
  55% {
    clip-path: inset(20% 0 80% 0);
  }
  60% {
    clip-path: inset(40% 0 50% 0);
  }
  65% {
    clip-path: inset(60% 0 30% 0);
  }
  70% {
    clip-path: inset(10% 0 60% 0);
  }
  75% {
    clip-path: inset(30% 0 40% 0);
  }
  80% {
    clip-path: inset(50% 0 20% 0);
  }
  85% {
    clip-path: inset(70% 0 10% 0);
  }
  90% {
    clip-path: inset(20% 0 30% 0);
  }
  95% {
    clip-path: inset(40% 0 60% 0);
  }
  100% {
    clip-path: inset(60% 0 20% 0);
  }
}

@media (max-width: 768px) {
  h1, h2 {
    font-size: 30px;
  }
  
  p {
    font-size: 16px;
  }
  
  button {
    font-size: 18px;
  }
  
  #score {
    font-size: 30px;
  }
}

#container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: none;
  pointer-events: none;
  z-index: 1;
}

#container #game {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 5;
}

#container .game-over {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 85%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    z-index: 20;
}

#container .game-over * {
    transition: opacity 0.5s ease, transform 0.5s ease;
    opacity: 0;
    transform: translatey(-50px);
    color: var(--secondary-color);
    text-shadow: 0 0 5px rgba(255, 62, 120, 0.7);
}

#container .game-over h2 {
    margin: 0;
    padding: 0;
    font-size: 50px;
    text-transform: uppercase;
    letter-spacing: 3px;
    animation: glitchText 2s infinite;
}

@keyframes glitchText {
    0% {
        text-shadow: 0 0 5px rgba(255, 62, 120, 0.7);
    }
    5% {
        text-shadow: -2px 0 var(--primary-color), 2px 0 var(--secondary-color);
    }
    10% {
        text-shadow: 2px 0 var(--shadow-color), -2px 0 var(--primary-color);
    }
    15% {
        text-shadow: 0 0 5px rgba(255, 62, 120, 0.7);
    }
    90% {
        text-shadow: 0 0 5px rgba(255, 62, 120, 0.7);
    }
    95% {
        text-shadow: 2px 2px var(--secondary-color), -2px -2px var(--shadow-color);
    }
    100% {
        text-shadow: 0 0 5px rgba(255, 62, 120, 0.7);
    }
}

#container .game-ready {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
    background: transparent;
    z-index: 20;
}

#container .game-ready #start-button {
    transition: all 0.3s ease;
    opacity: 0;
    transform: translatey(-50px);
    border: 2px solid var(--primary-color);
    padding: 15px 40px;
    background-color: rgba(0, 0, 0, 0.7);
    color: var(--primary-color);
    font-size: 24px;
    text-transform: uppercase;
    letter-spacing: 4px;
    cursor: pointer;
    font-family: 'Chakra Petch', sans-serif;
    position: relative;
    overflow: hidden;
    clip-path: polygon(
      0 0, 
      100% 0, 
      100% 70%, 
      90% 100%, 
      0 100%
    );
}

#container .game-ready #start-button:hover {
    background-color: rgba(6, 246, 255, 0.2);
    box-shadow: 0 0 20px rgba(6, 246, 255, 0.5);
    transform: translatey(0) scale(1.05);
}

#container .game-ready #start-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary-color));
    animation: animateTop 2s linear infinite;
}

@keyframes animateTop {
    0% {
        left: -100%;
    }
    50%, 100% {
        left: 100%;
    }
}

#container #instructions {
    position: absolute;
    width: 100%;
    top: 16vh;
    left: 0;
    text-align: center;
    transition: opacity 0.5s ease, transform 0.5s ease;
    opacity: 0;
    color: var(--text-color);
    font-size: 16px;
    letter-spacing: 1px;
    text-shadow: 0 0 5px rgba(231, 223, 251, 0.5);
    z-index: 10;
}

#container #instructions.hide {
    opacity: 0 !important;
}

#container.playing #score, 
#container.resetting #score {
    transform: translatey(0px) scale(1);
}

#container.playing #instructions {
    opacity: 0.7;
}

#container.ready .game-ready #start-button {
    opacity: 1;
    transform: translatey(0);
}

#container.ended #score {
    transform: translatey(6vh) scale(1.5);
    color: var(--secondary-color);
    animation: pulseScore 1.5s infinite;
}

@keyframes pulseScore {
    0% {
        text-shadow: 0 0 10px rgba(255, 62, 120, 0.7);
    }
    50% {
        text-shadow: 0 0 20px rgba(255, 62, 120, 1), 0 0 30px rgba(255, 62, 120, 0.5);
    }
    100% {
        text-shadow: 0 0 10px rgba(255, 62, 120, 0.7);
    }
}

#container.ended .game-over * {
    opacity: 1;
    transform: translatey(0);
}

#container.ended .game-over p {
    transition-delay: 0.3s;
    font-size: 18px;
    margin: 15px 0;
    letter-spacing: 1px;
} 