:root {
  color-scheme: light;
  --ink: #1b1b25;
  --muted: #63606f;
  --surface: #ffffff;
  --surface-soft: #f3f7fb;
  --line: #dfe6ee;
  --accent: #ed3f67;
  --focus: #1769ff;
  --shadow: 0 22px 70px rgba(26, 39, 66, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 18% 20%, rgba(255, 208, 73, 0.32), transparent 24rem),
    radial-gradient(circle at 82% 12%, rgba(40, 184, 170, 0.25), transparent 22rem),
    linear-gradient(180deg, #eef7ff 0%, #fff9f2 100%);
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

.game-shell {
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr);
  gap: 14px;
  width: min(100%, 1180px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 32px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: clamp(1.25rem, 2vw, 1.8rem);
  font-weight: 900;
  letter-spacing: 0;
  text-decoration: none;
}

.brand-mark {
  width: 28px;
  height: 34px;
  border-radius: 50% 50% 46% 46%;
  background: linear-gradient(145deg, #ff5a7c, #f0c33c);
  box-shadow: inset -6px -7px 0 rgba(105, 34, 68, 0.18);
}

.player-panel {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  min-width: 0;
}

.leaderboard-link {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 10px 28px rgba(31, 45, 71, 0.08);
}

.player-score {
  display: grid;
  justify-items: end;
  gap: 2px;
  min-width: 120px;
}

.player-score span {
  max-width: min(34vw, 260px);
  overflow: hidden;
  color: var(--muted);
  font-size: clamp(0.88rem, 1.2vw, 1rem);
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-score strong {
  font-size: clamp(2.5rem, 6vw, 5rem);
  line-height: 0.9;
}

.target-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 210px);
  align-items: start;
  gap: 24px;
  padding: 0;
}

.target-left {
  display: grid;
  align-content: space-between;
  gap: clamp(26px, 5.5vw, 68px);
  min-height: 100%;
}

.target-copy h1,
.leaderboard-view h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(2rem, 5.6vw, 4.9rem);
  line-height: 0.94;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.target-card {
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: var(--shadow);
}

.target-swatch {
  aspect-ratio: 1;
  width: 100%;
  border: 6px solid #ffffff;
  border-radius: 8px;
  background: #2487ff;
  box-shadow: inset 0 -14px 0 rgba(0, 0, 0, 0.12);
  transition: background-color 220ms ease;
}

.target-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-top: 10px;
  font-size: clamp(1rem, 1.5vw, 1.25rem);
  font-weight: 900;
}

.target-meta span:last-child {
  color: var(--muted);
}

.miss-counter {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(71, 88, 113, 0.16);
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 900;
}

.miss-counter strong {
  color: var(--accent);
}

.game-field {
  position: relative;
  display: grid;
  place-items: center;
  min-height: clamp(300px, 45vh, 520px);
  overflow: hidden;
  border: 2px dashed rgba(71, 88, 113, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.38);
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.field-line {
  position: absolute;
  inset: 18px;
  border-radius: 8px;
  border: 1px solid rgba(71, 88, 113, 0.16);
  pointer-events: none;
}

.play-button {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: clamp(88px, 15vw, 132px);
  aspect-ratio: 1;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.play-button:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 26px 80px rgba(26, 39, 66, 0.22);
}

.play-button:focus-visible {
  outline: 4px solid rgba(23, 105, 255, 0.34);
  outline-offset: 5px;
}

.play-button span {
  width: 0;
  height: 0;
  margin-left: 8%;
  border-top: clamp(17px, 3vw, 26px) solid transparent;
  border-bottom: clamp(17px, 3vw, 26px) solid transparent;
  border-left: clamp(27px, 4.8vw, 42px) solid #ffffff;
}

.play-button[hidden] {
  display: none;
}

.balloon {
  --balloon-color: #ef3e56;
  --balloon-size: 68px;
  --balloon-left: 50%;
  --balloon-drift: 0px;
  --balloon-exit-drift: 0px;
  --balloon-wobble: 0deg;
  --balloon-wobble-start: 0deg;
  --balloon-wobble-end: 0deg;
  --balloon-travel: 760px;
  --float-duration: 9000ms;
  position: absolute;
  left: var(--balloon-left);
  bottom: calc(var(--balloon-size) * -1.4);
  z-index: 1;
  width: var(--balloon-size);
  height: calc(var(--balloon-size) * 1.22);
  border-radius: 50% 50% 46% 46%;
  background:
    radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.72) 0 10%, transparent 18%),
    var(--balloon-color);
  box-shadow:
    inset -12px -16px 0 rgba(0, 0, 0, 0.14),
    0 12px 26px rgba(35, 45, 70, 0.14);
  cursor: pointer;
  pointer-events: auto;
  transform-origin: bottom center;
  animation: float-up var(--float-duration) linear forwards;
}

.balloon:focus-visible {
  outline: 4px solid rgba(23, 105, 255, 0.36);
  outline-offset: 6px;
}

.balloon::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  width: 16px;
  height: 12px;
  border-radius: 2px 2px 7px 7px;
  background: inherit;
  transform: translateX(-50%);
}

.balloon::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -42px;
  width: 2px;
  height: 36px;
  background: rgba(63, 73, 92, 0.32);
  transform: translateX(-50%);
}

.balloon.is-popped {
  pointer-events: none;
  animation: balloon-pop 260ms ease-out forwards;
}

.balloon.is-popped::before,
.balloon.is-popped::after {
  display: none;
}

.balloon.is-popped[data-points]::after {
  content: attr(data-points);
  position: absolute;
  inset: auto auto 50% 50%;
  display: block;
  width: auto;
  height: auto;
  background: transparent;
  color: var(--ink);
  font-size: 1.4rem;
  font-weight: 900;
  transform: translate(-50%, -50%);
}

@keyframes float-up {
  0% {
    opacity: 0;
    transform: translate3d(-50%, 0, 0) rotate(var(--balloon-wobble-start));
  }

  8% {
    opacity: 1;
  }

  50% {
    transform: translate3d(calc(-50% + var(--balloon-drift)), calc(var(--balloon-travel) * -0.5), 0) rotate(var(--balloon-wobble));
  }

  100% {
    opacity: 1;
    transform: translate3d(calc(-50% + var(--balloon-exit-drift)), calc(var(--balloon-travel) * -1), 0) rotate(var(--balloon-wobble-end));
  }
}

@keyframes balloon-pop {
  0% {
    opacity: 1;
    transform: translate3d(-50%, 0, 0) scale(1);
  }

  55% {
    opacity: 0.9;
    transform: translate3d(-50%, -12px, 0) scale(1.22);
  }

  100% {
    opacity: 0;
    transform: translate3d(-50%, -26px, 0) scale(0.18);
  }
}

.name-dialog {
  width: min(92vw, 440px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.game-over-dialog {
  width: min(92vw, 640px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.game-over-dialog::backdrop {
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 208, 73, 0.38), transparent 18rem),
    rgba(18, 25, 38, 0.56);
  backdrop-filter: blur(8px);
}

.game-over-content {
  position: relative;
  display: grid;
  gap: 16px;
  justify-items: center;
  overflow: hidden;
  padding: 34px 28px 30px;
  text-align: center;
  animation: game-over-pop 420ms cubic-bezier(0.18, 0.88, 0.32, 1.28);
}

.game-over-content > *:not(.fireworks) {
  position: relative;
  z-index: 1;
}

.fireworks {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.fireworks span {
  --burst-color: var(--accent);
  position: absolute;
  width: 86px;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--burst-color) 0 8%, transparent 9%),
    conic-gradient(
      from 0deg,
      transparent 0 8%,
      var(--burst-color) 8% 11%,
      transparent 11% 22%,
      var(--burst-color) 22% 25%,
      transparent 25% 38%,
      var(--burst-color) 38% 41%,
      transparent 41% 55%,
      var(--burst-color) 55% 58%,
      transparent 58% 72%,
      var(--burst-color) 72% 75%,
      transparent 75% 88%,
      var(--burst-color) 88% 91%,
      transparent 91% 100%
    );
  opacity: 0;
  transform: scale(0.2) rotate(0deg);
  animation: firework-burst 1200ms ease-out infinite;
}

.fireworks span:nth-child(1) {
  --burst-color: #f4c430;
  left: 10%;
  top: 12%;
}

.fireworks span:nth-child(2) {
  --burst-color: #2487ff;
  right: 10%;
  top: 16%;
  width: 72px;
  animation-delay: 220ms;
}

.fireworks span:nth-child(3) {
  --burst-color: #22a86f;
  left: 16%;
  bottom: 18%;
  width: 66px;
  animation-delay: 430ms;
}

.fireworks span:nth-child(4) {
  --burst-color: #ff7a1a;
  right: 14%;
  bottom: 16%;
  width: 78px;
  animation-delay: 640ms;
}

.game-over-content h2 {
  margin: 0;
  font-size: clamp(2.4rem, 8vw, 5.2rem);
  line-height: 0.92;
  letter-spacing: 0;
}

.game-over-content > strong {
  color: var(--accent);
  font-size: clamp(4rem, 16vw, 8rem);
  line-height: 0.88;
}

.game-over-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.game-over-actions button,
.game-over-actions a {
  display: inline-grid;
  place-items: center;
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  padding: 0 22px;
  cursor: pointer;
  font-weight: 900;
  text-decoration: none;
}

.game-over-actions button {
  background: var(--ink);
  color: #ffffff;
}

.game-over-actions a {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
}

.game-over-actions button:focus-visible,
.game-over-actions a:focus-visible {
  outline: 4px solid rgba(23, 105, 255, 0.28);
  outline-offset: 4px;
}

@keyframes game-over-pop {
  0% {
    opacity: 0;
    transform: scale(0.72) rotate(-2deg);
  }

  70% {
    opacity: 1;
    transform: scale(1.04) rotate(1deg);
  }

  100% {
    transform: scale(1) rotate(0);
  }
}

@keyframes firework-burst {
  0% {
    opacity: 0;
    transform: scale(0.14) rotate(0deg);
  }

  18% {
    opacity: 0.92;
  }

  72% {
    opacity: 0.52;
  }

  100% {
    opacity: 0;
    transform: scale(1.14) rotate(28deg);
  }
}

.name-dialog::backdrop {
  background: rgba(18, 25, 38, 0.42);
  backdrop-filter: blur(7px);
}

.name-dialog form {
  display: grid;
  gap: 14px;
  padding: 28px;
}

.name-dialog h2 {
  margin: 0 0 6px;
  font-size: clamp(2rem, 8vw, 3.6rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.name-dialog label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 900;
}

.name-dialog input {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 14px 15px;
  outline: 0;
}

.name-dialog input:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 4px rgba(23, 105, 255, 0.14);
}

.name-dialog button {
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: #ffffff;
  cursor: pointer;
  font-weight: 900;
}

.leaderboard-view {
  max-width: 900px;
  padding-top: 64px;
}

.leaderboard-list {
  display: grid;
  gap: 10px;
  margin: 34px 0 0;
  padding: 0;
  list-style-position: inside;
}

.leaderboard-list li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(112px, auto) auto;
  gap: 14px;
  align-items: center;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 10px 30px rgba(31, 45, 71, 0.08);
  font-size: clamp(1rem, 2vw, 1.35rem);
  font-weight: 900;
}

.leaderboard-list .rank {
  color: var(--accent);
}

.leaderboard-list .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-list .played-at {
  color: var(--muted);
  font-size: clamp(0.88rem, 1.4vw, 1rem);
  font-weight: 900;
  text-align: right;
  white-space: nowrap;
}

.leaderboard-list .score {
  font-size: clamp(1.4rem, 3vw, 2.2rem);
}

.empty-state {
  margin-top: 32px;
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 800;
}

@media (max-width: 760px) {
  .game-shell {
    grid-template-rows: auto minmax(420px, 1fr);
    gap: 14px;
    padding: 16px;
  }

  .top-bar {
    align-items: flex-start;
  }

  .player-panel {
    flex-direction: column-reverse;
    align-items: flex-end;
    gap: 10px;
  }

  .leaderboard-link {
    padding: 9px 11px;
    font-size: 0.88rem;
  }

  .target-stage {
    grid-template-columns: 1fr;
    gap: 14px;
    padding-top: 20px;
  }

  .target-left {
    gap: 28px;
  }

  .target-card {
    display: grid;
    grid-template-columns: 86px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    max-width: none;
  }

  .target-meta {
    display: grid;
    justify-content: start;
    padding-top: 0;
  }

  .game-field {
    min-height: clamp(360px, 58vh, 620px);
  }

  .leaderboard-list li {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .leaderboard-list .played-at {
    grid-column: 2 / 3;
    text-align: left;
  }

  .leaderboard-list .score {
    grid-column: 3 / 4;
    grid-row: 1 / span 2;
  }
}
