:root {
  --bg-dark: #0a0a12;
  --bg-mid: #12121f;
  --primary: #00f5d4;
  --primary-glow: rgba(0, 245, 212, 0.5);
  --accent: #ff6b35;
  --accent-glow: rgba(255, 107, 53, 0.5);
  --danger: #ff2e63;
  --success: #08f26e;
  --text: #e8e8e8;
  --text-dim: #6b6b8d;
  --card: rgba(18, 18, 31, 0.9);
  --border: rgba(0, 245, 212, 0.2);
}

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

html,
body {
  width: 100%;
  height: 100%;
}

body {
  font-family: "Rajdhani", sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  overflow: hidden;
  touch-action: manipulation;
}

.project-back-link,
.project-credit,
.project-hint {
  position: fixed;
  z-index: 40;
  backdrop-filter: blur(12px);
  background: rgba(10, 10, 18, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.24);
}

.project-back-link {
  top: 22px;
  left: 22px;
  padding: 12px 16px;
  border-radius: 999px;
  color: #ffffff;
  text-decoration: none;
  font-weight: 700;
}

.project-back-link:hover {
  color: #ffffff;
  text-decoration: none;
}

.project-credit {
  right: 22px;
  bottom: 22px;
  padding: 14px 18px;
  border-radius: 18px;
  display: grid;
  gap: 4px;
  text-align: right;
}

.project-credit span {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.project-credit strong {
  font-family: "Orbitron", sans-serif;
  color: var(--primary);
  font-size: 0.95rem;
}

.project-hint {
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  padding: 12px 16px;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.game-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.background {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(180deg, var(--bg-dark) 0%, #1a1a2e 50%, #16213e 100%);
}

.stars {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(2px 2px at 20px 30px, rgba(255, 255, 255, 0.8), transparent),
    radial-gradient(2px 2px at 40px 70px, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(1px 1px at 90px 40px, rgba(255, 255, 255, 0.6), transparent),
    radial-gradient(2px 2px at 130px 80px, rgba(255, 255, 255, 0.4), transparent),
    radial-gradient(1px 1px at 160px 120px, rgba(255, 255, 255, 0.7), transparent);
  background-size: 200px 200px;
  animation: starsMove 20s linear infinite;
}

@keyframes starsMove {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-200px);
  }
}

.grid-floor {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 120px;
  background:
    linear-gradient(90deg, var(--primary) 1px, transparent 1px),
    linear-gradient(180deg, var(--primary) 1px, transparent 1px);
  background-size: 50px 25px;
  opacity: 0.16;
  transform: perspective(500px) rotateX(60deg);
  transform-origin: bottom;
  animation: gridScroll 2s linear infinite;
}

@keyframes gridScroll {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 50px 0;
  }
}

.menu-screen,
.game-screen,
.death-screen,
.win-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.menu-screen.active,
.game-screen.active,
.death-screen.active,
.win-screen.active {
  opacity: 1;
  visibility: visible;
}

.menu-content {
  text-align: center;
  z-index: 20;
  padding: 0 24px;
}

.game-title {
  font-family: "Orbitron", sans-serif;
  font-size: clamp(3rem, 10vw, 6rem);
  font-weight: 900;
  line-height: 0.9;
  color: var(--text);
  text-shadow: 0 0 20px var(--primary-glow), 0 0 40px var(--primary-glow);
  margin-bottom: 0.5rem;
  animation: titlePulse 3s ease-in-out infinite;
}

.game-title span {
  color: var(--primary);
  display: block;
}

@keyframes titlePulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.02);
  }
}

.menu-subtitle {
  font-family: "Orbitron", sans-serif;
  font-size: 1.2rem;
  color: var(--accent);
  letter-spacing: 0.5em;
  margin-bottom: 3rem;
}

.btn-play,
.btn-retry,
.btn-menu,
.btn-next {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem 3rem;
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
  font-family: "Orbitron", sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.25s ease;
}

.btn-play::before,
.btn-retry::before,
.btn-next::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--primary);
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  z-index: -1;
}

.btn-play:hover,
.btn-retry:hover,
.btn-next:hover {
  color: var(--bg-dark);
  box-shadow: 0 0 30px var(--primary-glow);
}

.btn-play:hover::before,
.btn-retry:hover::before,
.btn-next:hover::before {
  transform: translateX(0);
}

.btn-menu {
  border-color: var(--text-dim);
  color: var(--text-dim);
}

.btn-menu:hover {
  border-color: var(--text);
  color: var(--text);
}

.btn-retry,
.btn-menu,
.btn-next {
  display: block;
  width: 100%;
  margin-bottom: 1rem;
}

.high-score {
  margin-top: 2rem;
  font-family: "Orbitron", sans-serif;
  font-size: 1.1rem;
  color: var(--text-dim);
}

.high-score span {
  color: var(--accent);
  font-weight: 700;
}

.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 1.5rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  z-index: 15;
  background: linear-gradient(180deg, rgba(10, 10, 18, 0.9) 0%, transparent 100%);
}

.score-display,
.attempts {
  display: flex;
  flex-direction: column;
}

.attempts {
  align-items: flex-end;
}

.score-label,
.attempts span:first-child,
.final-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  letter-spacing: 0.2em;
}

.score-value,
.attempts span:last-child,
.final-value {
  font-family: "Orbitron", sans-serif;
  font-weight: 700;
}

.score-value {
  font-size: 2rem;
  color: var(--primary);
}

.attempts span:last-child {
  font-size: 1.5rem;
  color: var(--accent);
}

.progress-bar {
  flex: 1;
  max-width: 320px;
  height: 10px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 999px;
  transition: width 0.1s linear;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.death-content,
.win-content {
  text-align: center;
  background: var(--card);
  padding: 3rem 4rem;
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  box-shadow: 0 28px 56px rgba(0, 0, 0, 0.3);
}

.death-title,
.win-title {
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  margin-bottom: 1.5rem;
}

.death-title {
  font-size: 3rem;
  color: var(--danger);
  text-shadow: 0 0 20px rgba(255, 46, 99, 0.5);
}

.win-title {
  font-size: 2.5rem;
  color: var(--success);
  text-shadow: 0 0 20px rgba(8, 242, 110, 0.5);
}

.final-score {
  margin-bottom: 1.5rem;
}

.final-value {
  font-size: 3.5rem;
  color: var(--primary);
}

.new-record {
  font-family: "Orbitron", sans-serif;
  font-size: 1.2rem;
  color: var(--success);
  margin-bottom: 2rem;
  opacity: 0;
}

.new-record.show {
  opacity: 1;
  animation: recordPulse 1s ease-in-out infinite;
}

@keyframes recordPulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.08);
    opacity: 0.82;
  }
}

.stars-rating {
  margin-bottom: 2rem;
}

.star {
  font-size: 3rem;
  color: var(--text-dim);
  margin: 0 0.25rem;
  transition: all 0.3s ease;
}

.star.earned {
  color: var(--accent);
  text-shadow: 0 0 15px var(--accent-glow);
  animation: starPop 0.5s ease-out forwards;
}

@keyframes starPop {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.3);
  }
  100% {
    transform: scale(1);
  }
}

button,
.game-container {
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 768px) {
  .project-back-link {
    top: 14px;
    left: 14px;
    padding: 10px 14px;
  }

  .project-credit,
  .project-hint {
    display: none;
  }

  .hud {
    padding: 1rem;
    flex-wrap: wrap;
  }

  .progress-bar {
    order: 3;
    max-width: 100%;
    flex-basis: 100%;
  }

  .death-content,
  .win-content {
    padding: 2rem;
    margin: 1rem;
  }

  .btn-play,
  .btn-retry,
  .btn-menu,
  .btn-next {
    width: 100%;
    padding: 0.9rem 1.6rem;
    font-size: 1rem;
  }
}
