* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #08080d;
  color: #fff;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: none;
  user-select: none;
}

body {
  position: fixed;
  inset: 0;
}

button {
  font: inherit;
}

.game-shell {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 82%, rgba(244, 77, 255, 0.18), transparent 34%),
    radial-gradient(circle at 85% 16%, rgba(57, 209, 159, 0.16), transparent 30%),
    #08080d;
}

#game {
  position: fixed;
  inset: 0;
  width: 100vw !important;
  width: 100dvw !important;
  height: 100vh !important;
  height: 100dvh !important;
  display: block;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  border: 0 !important;
  background: #101012;
}

.hud,
.leaderboard,
.prompt,
.pause-button {
  position: fixed;
  z-index: 5;
}

.hud {
  top: max(16px, env(safe-area-inset-top));
  left: max(16px, env(safe-area-inset-left));
  right: max(16px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}

.brand,
.stats,
.leaderboard {
  border: 1px solid rgba(244, 77, 255, 0.34);
  background: rgba(12, 10, 18, 0.74);
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
}

.brand {
  min-height: 46px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border-radius: 999px;
  font-weight: 1000;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: conic-gradient(#d33568, #39d19f, #3e83d8, #f04cff, #d33568);
  box-shadow: 0 0 20px rgba(240, 76, 255, 0.7);
}

.stats {
  min-height: 46px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 999px;
}

.stats span {
  display: inline-flex;
  gap: 6px;
  align-items: baseline;
  white-space: nowrap;
}

.stats b,
.leaderboard-head span {
  color: #f04cff;
  font-size: 12px;
  font-weight: 1000;
  text-transform: uppercase;
}

.stats strong {
  font-size: 18px;
  font-weight: 1000;
}

.stats [data-stat="best"] {
  display: none;
}

body.game-over .stats [data-stat="best"] {
  display: inline-flex;
}

.leaderboard {
  left: 50%;
  top: max(84px, calc(env(safe-area-inset-top) + 84px));
  width: min(520px, calc(100vw - 32px));
  padding: 14px;
  display: none;
  border-radius: 8px;
  transform: translateX(-50%);
  z-index: 8;
}

body.game-over .leaderboard {
  display: block;
}

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

.leaderboard-head strong {
  color: #39d19f;
  font-size: 12px;
}

.leaderboard ol {
  display: grid;
  gap: 6px;
  max-height: min(58vh, 460px);
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: hidden;
}

.leaderboard li {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  padding: 5px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
  font-size: 13px;
  font-weight: 900;
}

.leaderboard .empty {
  grid-template-columns: 1fr;
  color: rgba(255, 255, 255, 0.7);
}

.prompt {
  left: 50%;
  top: 50%;
  width: min(460px, calc(100vw - 32px));
  padding: 22px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(244, 77, 255, 0.54);
  border-radius: 8px;
  background: rgba(8, 8, 13, 0.88);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.55), 10px 10px 0 #7428d8;
  text-align: center;
  backdrop-filter: blur(14px);
  z-index: 9;
}

.prompt.hidden {
  display: none;
}

.prompt h1 {
  margin: 0;
  font-size: clamp(42px, 8vw, 74px);
  line-height: 0.95;
  letter-spacing: 0;
  text-shadow: 0 8px 0 #6223bc;
}

.prompt p {
  margin: 16px 0 20px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 16px;
  font-weight: 800;
}

.prompt button {
  width: 100%;
  min-height: 54px;
  border: 2px solid #050507;
  border-radius: 999px;
  background: linear-gradient(90deg, #f04cff, #ff4fd8);
  color: #08080d;
  box-shadow: 9px 9px 0 #7428d8;
  cursor: pointer;
  font-size: 18px;
  font-weight: 1000;
  text-transform: uppercase;
}

.pause-button {
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  width: 54px;
  height: 54px;
  border: 2px solid rgba(244, 77, 255, 0.78);
  border-radius: 50%;
  background: rgba(12, 10, 18, 0.78);
  color: #ffffff;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.36), 6px 6px 0 #7428d8;
  cursor: pointer;
  font-size: 18px;
  font-weight: 1000;
  line-height: 1;
  z-index: 6;
  backdrop-filter: blur(10px);
}

@media (max-width: 760px) {
  .hud {
    align-items: stretch;
    flex-direction: column;
  }

  .brand,
  .stats {
    width: 100%;
    justify-content: center;
  }

  .leaderboard {
    top: 132px;
    width: min(358px, calc(100vw - 32px));
  }

  .leaderboard ol {
    max-height: min(45vh, 360px);
  }
}
