:root {
  --bg-start: #06222f;
  --bg-mid: #0f4a5a;
  --bg-end: #f6b73c;
  --panel: #04202b;
  --ink: #f9f7f0;
  --accent: #f95012;
  --accent-2: #f6d743;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 15%, #2e8a99 0%, transparent 30%),
    linear-gradient(140deg, var(--bg-start), var(--bg-mid) 56%, var(--bg-end));
  overflow-x: hidden;
}

.bg-shape {
  position: fixed;
  pointer-events: none;
  z-index: -1;
  filter: blur(40px);
  opacity: 0.5;
}

.bg-shape-a {
  width: 320px;
  height: 320px;
  border-radius: 54% 46% 43% 57% / 56% 40% 60% 44%;
  background: #ff6b35;
  top: -60px;
  right: -60px;
  animation: driftA 9s ease-in-out infinite;
}

.bg-shape-b {
  width: 240px;
  height: 240px;
  border-radius: 60% 40% 50% 50% / 42% 62% 38% 58%;
  background: #ffd166;
  bottom: -40px;
  left: -30px;
  animation: driftB 7s ease-in-out infinite;
}

@keyframes driftA {
  0% {
    transform: translate(0, 0) rotate(0deg);
  }
  50% {
    transform: translate(-16px, 14px) rotate(7deg);
  }
  100% {
    transform: translate(0, 0) rotate(0deg);
  }
}

@keyframes driftB {
  0% {
    transform: translate(0, 0) rotate(0deg);
  }
  50% {
    transform: translate(12px, -10px) rotate(-8deg);
  }
  100% {
    transform: translate(0, 0) rotate(0deg);
  }
}

.shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 16px 32px;
}

.hud-top {
  margin-bottom: 14px;
  animation: reveal 800ms ease-out;
}

.hud-top h1 {
  font-family: "Bungee", cursive;
  font-size: clamp(1.6rem, 2.4vw + 1rem, 2.8rem);
  margin: 0 0 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.hud-top p {
  margin: 0;
  line-height: 1.35;
  font-size: clamp(0.95rem, 1.2vw + 0.4rem, 1.1rem);
}

.kbd {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 8px;
  background: rgba(4, 32, 43, 0.75);
  border: 1px solid rgba(246, 215, 67, 0.5);
  font-weight: 700;
}

.game-wrap {
  border-radius: 20px;
  background: linear-gradient(170deg, rgba(1, 11, 17, 0.8), rgba(8, 23, 31, 0.95));
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  animation: reveal 1200ms ease-out;
}

.start-screen {
  margin-top: 14px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(4, 32, 43, 0.68);
  border: 1px solid rgba(255, 255, 255, 0.15);
  max-width: 560px;
}

.game-layout {
  margin-top: 14px;
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
}

.game-layout.with-leaderboard {
  grid-template-columns: minmax(0, 3fr) minmax(260px, 1fr);
}

.start-form {
  display: grid;
  gap: 10px;
}

.start-form label {
  font-weight: 700;
}

.start-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.start-row input {
  flex: 1;
  min-width: 220px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(1, 11, 17, 0.7);
  color: var(--ink);
  font: inherit;
}

.start-row button {
  padding: 10px 16px;
  border: 1px solid rgba(246, 215, 67, 0.5);
  background: rgba(249, 80, 18, 0.2);
  color: var(--ink);
  border-radius: 10px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.leaderboard {
  border-radius: 16px;
  background: rgba(4, 32, 43, 0.68);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 14px;
  max-height: 540px;
  overflow-y: auto;
}

.leaderboard h2 {
  margin: 0 0 10px;
  font-size: 1.15rem;
}

.leaderboard ol {
  margin: 0;
  padding-left: 22px;
}

.leaderboard li {
  margin: 4px 0;
}

.panel-message {
  margin: 0;
  color: var(--accent-2);
  font-size: 0.96rem;
}

#game {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  image-rendering: crisp-edges;
}

@keyframes reveal {
  from {
    transform: translateY(12px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 720px) {
  .shell {
    padding: 16px 10px 24px;
  }

  .game-layout,
  .game-layout.with-leaderboard {
    grid-template-columns: 1fr;
  }
}
