:root {
  color-scheme: light;
  font-family: "Avenir Next", "Trebuchet MS", Verdana, sans-serif;
  background: #f8f4d8;
  color: #203238;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at 18% 20%, rgba(255, 203, 5, 0.25), transparent 24rem),
    radial-gradient(circle at 86% 72%, rgba(61, 125, 202, 0.18), transparent 28rem),
    linear-gradient(135deg, #fff6c9 0%, #d9f3c6 48%, #bfe6ff 100%);
}

.shell {
  position: relative;
  min-height: 100vh;
}

.shell::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(42, 117, 187, 0.1) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 50% 50%, transparent 22%, black 74%);
}

#arena {
  display: block;
  width: 100vw;
  height: 100vh;
  background: #d7f2b7;
  touch-action: none;
}

.hud {
  position: absolute;
  z-index: 2;
  display: grid;
  gap: 0.55rem;
  width: min(18rem, calc(100vw - 2rem));
  padding: 0.85rem;
  border: 3px solid #2a75bb;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 248, 204, 0.88)),
    repeating-linear-gradient(135deg, transparent 0 10px, rgba(255, 203, 5, 0.09) 10px 20px);
  box-shadow: 0 10px 0 rgba(61, 125, 202, 0.28), 0 22px 42px rgba(29, 67, 91, 0.22);
  backdrop-filter: blur(9px);
}

.hud::after {
  content: "";
  position: absolute;
  right: 0.7rem;
  top: 0.7rem;
  width: 1.15rem;
  height: 1.15rem;
  border: 2px solid #243746;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #fff 0 18%, #243746 19% 27%, transparent 28%),
    linear-gradient(#ee1515 0 48%, #243746 49% 53%, #fff 54% 100%);
  opacity: 0.88;
}

.hud-left {
  top: 1rem;
  left: 1rem;
}

.hud-right {
  top: 1rem;
  right: 1rem;
}

.brand,
.panel-title {
  color: #2a3a7f;
  font-size: 0.88rem;
  font-weight: 900;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  text-shadow: 1px 1px 0 #ffcb05;
}

.metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 1.6rem;
  gap: 1rem;
  padding: 0.12rem 0;
  border-bottom: 1px dashed rgba(42, 117, 187, 0.24);
  font-size: 0.82rem;
}

.metric span,
#leaderboard {
  color: rgba(32, 50, 56, 0.72);
}

.metric strong {
  color: #1f7a46;
  font-variant-numeric: tabular-nums;
}

#leaderboard {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding-left: 1.35rem;
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
}

#leaderboard li::marker {
  color: #ee1515;
  font-weight: 900;
}

.touch-controls {
  position: absolute;
  inset: auto 0 0;
  z-index: 3;
  display: none;
  pointer-events: none;
  touch-action: none;
}

.stick-zone,
.fire-button {
  pointer-events: auto;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.stick-zone {
  position: absolute;
  left: max(1rem, env(safe-area-inset-left));
  bottom: max(1rem, env(safe-area-inset-bottom));
  width: 9.5rem;
  height: 9.5rem;
  display: grid;
  place-items: center;
}

.stick-base {
  position: relative;
  width: 7.6rem;
  height: 7.6rem;
  border: 3px solid rgba(42, 117, 187, 0.62);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 203, 5, 0.24), transparent 34%),
    rgba(255, 255, 255, 0.74);
  box-shadow: inset 0 -10px 0 rgba(42, 117, 187, 0.12), 0 18px 38px rgba(29, 67, 91, 0.28);
  backdrop-filter: blur(8px);
}

.stick-base::before,
.stick-base::after {
  content: "";
  position: absolute;
  inset: 50% 1.2rem auto;
  height: 2px;
  background: rgba(42, 117, 187, 0.26);
}

.stick-base::after {
  inset: 1.2rem auto;
  left: 50%;
  width: 2px;
  height: auto;
}

.stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 3.2rem;
  height: 3.2rem;
  border: 3px solid #243746;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #fff 0 17%, #243746 18% 26%, transparent 27%),
    linear-gradient(#ee1515 0 48%, #243746 49% 54%, #fff 55% 100%);
  box-shadow: 0 0 0 6px rgba(255, 203, 5, 0.16), 0 10px 20px rgba(29, 67, 91, 0.24);
  transform: translate(-50%, -50%);
}

.stick-zone.is-active .stick-base {
  border-color: #ffcb05;
}

.fire-button {
  position: absolute;
  right: max(1.25rem, env(safe-area-inset-right));
  bottom: max(1.55rem, env(safe-area-inset-bottom));
  width: 6.4rem;
  height: 6.4rem;
  border: 4px solid #243746;
  border-radius: 50%;
  color: #243746;
  background:
    radial-gradient(circle at 50% 50%, #fff 0 14%, #243746 15% 23%, transparent 24%),
    linear-gradient(#ee1515 0 47%, #243746 48% 53%, #fff 54% 100%);
  box-shadow: 0 0 0 8px rgba(238, 21, 21, 0.1), 0 18px 40px rgba(29, 67, 91, 0.35);
  font: inherit;
  font-size: 0;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.fire-button.is-active {
  transform: scale(0.94) rotate(-8deg);
  box-shadow: 0 0 0 13px rgba(255, 203, 5, 0.2), 0 8px 24px rgba(29, 67, 91, 0.42);
}

.death-modal {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(27, 54, 71, 0.42);
  backdrop-filter: blur(7px);
}

.death-modal[hidden] {
  display: none;
}

.death-panel {
  width: min(21rem, calc(100vw - 2rem));
  display: grid;
  gap: 1rem;
  padding: 1.1rem;
  border: 3px solid #ee1515;
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #fff4c2);
  box-shadow: 0 24px 70px rgba(29, 67, 91, 0.38);
  text-align: center;
}

.death-score {
  color: rgba(32, 50, 56, 0.72);
  font-size: 0.9rem;
}

.death-score strong {
  color: #2a3a7f;
  font-size: 1.45rem;
  font-variant-numeric: tabular-nums;
}

.respawn-button {
  min-height: 3rem;
  border: 2px solid #243746;
  border-radius: 6px;
  color: #243746;
  background: #ffcb05;
  font: inherit;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: inset 0 -4px 0 rgba(42, 117, 187, 0.22);
}

.respawn-button:active {
  transform: translateY(1px);
}

.game-links {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  justify-content: center;
}

.game-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.88);
  border: 2px solid #2a75bb;
  border-radius: 100px;
  color: #2a3a7f;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  backdrop-filter: blur(6px);
  white-space: nowrap;
  box-shadow: 0 10px 24px rgba(29, 67, 91, 0.18);
}

.game-links a:hover {
  border-color: #ee1515;
  color: #ee1515;
  background: #fff8d5;
}

@media (max-width: 760px) {
  body {
    background: #d9f3c6;
  }

  .hud {
    top: max(0.7rem, env(safe-area-inset-top));
    left: 0.7rem;
    width: min(15rem, calc(100vw - 1.4rem));
    grid-template-columns: 1fr 1fr;
    align-items: center;
    gap: 0.35rem 0.8rem;
    padding: 0.62rem 0.7rem;
  }

  .brand {
    grid-column: 1 / -1;
    font-size: 0.75rem;
  }

  .metric {
    min-height: 1.25rem;
    gap: 0.55rem;
    font-size: 0.74rem;
  }

  .metric-meta,
  .hud-right {
    display: none;
  }

  .touch-controls {
    display: block;
  }

  .game-links {
    bottom: calc(8rem + env(safe-area-inset-bottom));
  }
}

@media (hover: none) and (pointer: coarse) {
  .touch-controls {
    display: block;
  }
}
