html, body {
  margin: 0;
  min-height: 100%;
  overflow-x: clip;
  background:
    radial-gradient(1100px 420px at 50% -80px, rgba(150, 107, 255, 0.16), transparent 70%),
    radial-gradient(900px 380px at 85% 20%, rgba(70, 228, 255, 0.07), transparent 70%),
    #0a0a1a;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #f0f0ff;
}

.page {
  max-width: 880px;
  margin: 0 auto;
  padding: 28px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-sizing: border-box;
}

.game-header {
  text-align: center;
  display: grid;
  gap: 4px;
  justify-items: center;
}

.game-header h1 {
  margin: 0;
  font-size: clamp(28px, 6vw, 42px);
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, #966bff, #f06bd8 55%, #46e4ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 0;
  color: #a0a0c0;
  font-size: 13px;
}

.back-link {
  font-size: 13px;
  color: #a0a0c0;
  text-decoration: none;
  justify-self: start;
}

.back-link:hover {
  color: #f0f0ff;
}

.game-frame {
  position: relative;
  border-radius: 14px;
  padding: 6px;
  background: linear-gradient(140deg, rgba(150, 107, 255, 0.55), rgba(35, 38, 74, 0.6) 35%, rgba(70, 228, 255, 0.45));
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), 0 0 42px rgba(150, 107, 255, 0.14);
}

canvas#game {
  width: 100%;
  display: block;
  aspect-ratio: 800 / 300;
  background: #0a0a1a;
  border-radius: 10px;
  touch-action: manipulation;
}

.hint {
  margin: 0;
  font-size: 13px;
  color: #a0a0c0;
  text-align: center;
}

.panels {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  align-items: start;
}

.sprite-picker,
.leaderboard {
  border: 1px solid #23264a;
  border-radius: 12px;
  background: rgba(17, 19, 39, 0.86);
  padding: 14px;
  box-sizing: border-box;
}

.sprite-picker-head,
.leaderboard-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
  margin-bottom: 10px;
}

.sprite-picker h2,
.leaderboard h2 {
  margin: 0;
  font-size: 15px;
}

.sprite-picker p,
.leaderboard p {
  margin: 2px 0 0;
  color: #a0a0c0;
  font-size: 12px;
}

.sprite-picker-head > span {
  flex: 0 0 auto;
  color: #f0f0ff;
  font-size: 12px;
  font-weight: 700;
}

.leaderboard-head label {
  display: grid;
  gap: 4px;
  color: #a0a0c0;
  font-size: 11px;
}

.leaderboard-head input {
  width: 130px;
  border: 1px solid #23264a;
  border-radius: 8px;
  background: #0a0a1a;
  color: #f0f0ff;
  padding: 8px 9px;
  font: inherit;
}

.leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.leaderboard-list li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) minmax(0, 96px) auto;
  gap: 10px;
  align-items: center;
  min-height: 32px;
  border: 1px solid rgba(35, 38, 74, 0.72);
  border-radius: 9px;
  background: rgba(10, 10, 26, 0.55);
  padding: 5px 9px;
  color: #f0f0ff;
  font-size: 12px;
}

.leaderboard-list .empty {
  display: block;
  color: #a0a0c0;
  text-align: center;
  padding: 14px 0;
}

.leaderboard-list .rank {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #23264a;
  font-weight: 800;
}

.leaderboard-list li:nth-child(1) .rank { background: #ffd36f; color: #0a0a1a; }
.leaderboard-list li:nth-child(2) .rank { background: #cfd6e4; color: #0a0a1a; }
.leaderboard-list li:nth-child(3) .rank { background: #d69a6b; color: #0a0a1a; }

.leaderboard-list .who,
.leaderboard-list .cat {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.leaderboard-list .cat {
  color: #a0a0c0;
}

.sprite-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
}

.sprite-card {
  position: relative;
  min-width: 0;
  border: 1px solid color-mix(in srgb, var(--sprite-accent), transparent 40%);
  border-radius: 10px;
  background: #0f1128;
  color: #f0f0ff;
  padding: 7px 6px 8px;
  font: inherit;
  text-align: center;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.sprite-card:not(.locked):not(.active):hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}

.sprite-card.active {
  box-shadow: 0 0 0 2px var(--sprite-accent), 0 10px 24px rgba(0, 0, 0, 0.24);
}

.sprite-card.locked {
  cursor: not-allowed;
  opacity: 0.46;
  filter: grayscale(0.78);
}

.sprite-card img {
  width: 54px;
  height: 54px;
  object-fit: contain;
  display: block;
  margin: 0 auto 4px;
}

.sprite-name,
.sprite-meta {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sprite-name {
  font-size: 11px;
  font-weight: 700;
}

.sprite-meta {
  color: #a0a0c0;
  font-size: 10px;
}

@media (max-width: 820px) {
  .panels {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .page {
    padding-top: 18px;
  }

  .sprite-picker-head,
  .leaderboard-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .leaderboard-head input {
    width: min(240px, calc(100vw - 56px));
  }

  .sprite-grid {
    display: flex;
    overflow-x: auto;
    padding-bottom: 4px;
    scroll-snap-type: x proximity;
  }

  .sprite-card {
    flex: 0 0 82px;
    scroll-snap-align: start;
  }
}
