:root {
  --sky-top: #8fd3ff;
  --sky-bottom: #dff7ff;
  --grass-top: #9be46e;
  --grass-bottom: #6ecb5d;
  --card-bg: rgba(255, 255, 255, 0.9);
  --text-main: #24506b;
  --text-soft: #4d7891;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Trebuchet MS", "PingFang SC", "Microsoft YaHei", sans-serif;
}

body {
  min-height: 100vh;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 70%);
  color: var(--text-main);
}

.game-screen {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
}

.top-hud {
  position: absolute;
  top: 18px;
  left: 18px;
  right: 18px;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(320px, 1fr) minmax(240px, 300px);
  gap: 16px;
  align-items: start;
}

.hud-panel {
  padding: 14px 16px;
  border-radius: 24px;
  background: var(--card-bg);
  box-shadow: 0 16px 40px rgba(58, 119, 156, 0.18);
  backdrop-filter: blur(6px);
}

.hud-panel-center {
  text-align: center;
}

.hud-panel-right {
  justify-self: end;
  width: 100%;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 700;
  color: #ff8d3b;
}

.hud-panel h1 {
  margin: 0;
  font-size: clamp(32px, 5vw, 48px);
  line-height: 1.1;
}

.instruction {
  margin: 8px 0 0;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text-soft);
}

.status-stack {
  display: grid;
  gap: 10px;
}

.player-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-badge {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 0 0 1px rgba(109, 140, 161, 0.12);
}

.player-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: #6b8ba0;
}

.player-name {
  display: block;
  margin-top: 2px;
  font-size: 18px;
  line-height: 1.2;
  color: #24506b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leaderboard-button,
.close-button {
  border: 0;
  cursor: pointer;
}

.leaderboard-button {
  flex: 0 0 auto;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(180deg, #52b8ff 0%, #2a8fe9 100%);
  box-shadow: 0 8px 18px rgba(42, 143, 233, 0.24);
}

.score-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 12px 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 248, 200, 0.92) 0%, rgba(255, 240, 154, 0.95) 100%);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.55);
}

.score-label {
  font-size: 16px;
  font-weight: 700;
  color: #7f6110;
}

.score-value {
  font-size: clamp(30px, 4.8vw, 42px);
  line-height: 1;
  color: #ff7b1b;
}

.timer-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(227, 245, 255, 0.95) 0%, rgba(190, 232, 255, 0.96) 100%);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.58);
}

.timer-label {
  font-size: 16px;
  font-weight: 700;
  color: #286786;
}

.timer-value {
  font-size: clamp(24px, 4vw, 34px);
  line-height: 1.1;
  color: #1b7fd9;
}

.top-three-card {
  margin: 10px 0 0;
  padding: 10px 10px 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: inset 0 0 0 1px rgba(109, 140, 161, 0.12);
}

.top-three-title {
  font-size: 12px;
  font-weight: 700;
  color: #648399;
}

.top-three-list {
  margin-top: 6px;
}

.top-three-item,
.leaderboard-item {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 8px;
}

.top-three-item + .top-three-item,
.leaderboard-item + .leaderboard-item {
  margin-top: 6px;
}

.top-three-rank,
.leaderboard-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  color: #ffffff;
  background: linear-gradient(180deg, #ffb648 0%, #ff8f24 100%);
}

.top-three-rank.rank-2,
.leaderboard-rank.rank-2 {
  background: linear-gradient(180deg, #7dc7ff 0%, #4ea9f1 100%);
}

.top-three-rank.rank-3,
.leaderboard-rank.rank-3 {
  background: linear-gradient(180deg, #8fd36c 0%, #58b44d 100%);
}

.top-three-name,
.leaderboard-name {
  min-width: 0;
  font-size: 13px;
  font-weight: 700;
  color: #35566b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-three-score,
.leaderboard-score {
  font-size: 13px;
  font-weight: 800;
  color: #ff7b1b;
}

.empty-text {
  font-size: 12px;
  color: #6b8ba0;
}

.score-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.64);
  box-shadow: inset 0 0 0 1px rgba(109, 140, 161, 0.12);
}

.score-chip-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 3px 8px rgba(58, 119, 156, 0.18);
  flex: 0 0 auto;
}

.score-chip-text {
  font-size: 12px;
  font-weight: 700;
  color: #3f6278;
}

.special-note {
  margin: 8px 0 0;
  font-size: 12px;
  font-weight: 700;
  color: #ff7b1b;
}

.music-tip {
  margin: 6px 0 0;
  font-size: 12px;
  color: #6d8ca1;
}

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

.game-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(120, 198, 255, 0.26);
  backdrop-filter: blur(6px);
}

.game-overlay.hidden {
  display: none;
}

.overlay-card {
  width: min(360px, calc(100vw - 48px));
  padding: 26px 24px 24px;
  border-radius: 28px;
  text-align: center;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 44px rgba(47, 110, 150, 0.22);
}

.overlay-eyebrow {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #ff8c45;
}

.overlay-card h2 {
  margin: 8px 0 0;
  font-size: clamp(30px, 5vw, 38px);
  color: #2f6283;
}

.overlay-score {
  margin: 12px 0 18px;
  font-size: clamp(48px, 9vw, 72px);
  font-weight: 800;
  line-height: 1;
  color: #ff7b1b;
}

.name-card {
  text-align: left;
}

.name-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.name-input {
  width: 100%;
  border: 2px solid rgba(82, 184, 255, 0.28);
  border-radius: 16px;
  padding: 14px 16px;
  font-size: 18px;
  font-weight: 700;
  color: #24506b;
  outline: none;
}

.name-input:focus {
  border-color: rgba(42, 143, 233, 0.68);
  box-shadow: 0 0 0 4px rgba(82, 184, 255, 0.16);
}

.leaderboard-card {
  width: min(420px, calc(100vw - 48px));
  text-align: left;
}

.leaderboard-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.close-button {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  font-size: 24px;
  line-height: 1;
  color: #5d7a91;
  background: rgba(93, 122, 145, 0.1);
}

.leaderboard-list {
  margin-top: 16px;
  max-height: min(52vh, 420px);
  overflow: auto;
  padding-right: 2px;
}

.leaderboard-item {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(242, 249, 255, 0.8);
}

.restart-button {
  border: 0;
  border-radius: 999px;
  padding: 14px 26px;
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(180deg, #ff8f48 0%, #ff6b39 100%);
  box-shadow: 0 10px 22px rgba(255, 120, 74, 0.34);
  cursor: pointer;
}

.restart-button:hover {
  transform: translateY(-1px);
}

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

.playground::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 22vh;
  min-height: 130px;
  background: linear-gradient(180deg, var(--grass-top) 0%, var(--grass-bottom) 100%);
}

.sun {
  position: absolute;
  top: 90px;
  right: 140px;
  width: 108px;
  height: 108px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff8a8 0%, #ffd95e 58%, #ffb938 100%);
  box-shadow: 0 0 0 16px rgba(255, 228, 122, 0.22);
}

.cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  filter: drop-shadow(0 10px 10px rgba(88, 144, 176, 0.12));
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: inherit;
}

.cloud-left {
  top: 140px;
  left: 8%;
  width: 130px;
  height: 40px;
}

.cloud-left::before {
  left: 14px;
  bottom: 12px;
  width: 48px;
  height: 48px;
}

.cloud-left::after {
  right: 18px;
  bottom: 10px;
  width: 58px;
  height: 58px;
}

.cloud-right {
  top: 220px;
  right: 14%;
  width: 150px;
  height: 46px;
}

.cloud-right::before {
  left: 18px;
  bottom: 12px;
  width: 54px;
  height: 54px;
}

.cloud-right::after {
  right: 20px;
  bottom: 12px;
  width: 60px;
  height: 60px;
}

.balloon {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: -180px;
  width: 96px;
  height: 122px;
  margin-left: -48px;
  border: 0;
  padding: 0;
  cursor: pointer;
  background: transparent;
  will-change: transform;
  --balloon-main: #ff6fae;
  --balloon-shadow: #e45694;
  --balloon-glow: #ffd4e5;
}

.balloon-art {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  animation: sway 2.4s ease-in-out infinite;
}

.balloon.special-bonus .balloon-art,
.balloon.special-penalty .balloon-art {
  animation-duration: 1.7s;
}

.balloon-body {
  position: absolute;
  inset: 0;
  border-radius: 50% 50% 46% 46%;
  background: radial-gradient(circle at 30% 28%, var(--balloon-glow) 0%, var(--balloon-main) 45%, var(--balloon-shadow) 100%);
}

.balloon.special-bonus .balloon-body,
.balloon.special-penalty .balloon-body {
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.75), 0 0 26px var(--balloon-glow);
}

.balloon.special-bonus .balloon-body {
  animation: special-pulse 0.9s ease-in-out infinite;
}

.balloon.special-penalty .balloon-body {
  animation: warning-pulse 0.8s ease-in-out infinite;
}

.balloon-body::after {
  content: "";
  position: absolute;
  top: 20px;
  left: 22px;
  width: 18px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  transform: rotate(18deg);
}

.balloon-knot {
  position: absolute;
  left: 50%;
  bottom: -8px;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  background: var(--balloon-shadow);
  clip-path: polygon(50% 100%, 0 0, 100% 0);
}

.balloon-string {
  position: absolute;
  left: 50%;
  top: 120px;
  width: 2px;
  height: 110px;
  margin-left: -1px;
  background: linear-gradient(180deg, #f8f8f8 0%, #d9f2ff 100%);
}

.balloon-badge {
  position: absolute;
  left: 50%;
  top: 38px;
  min-width: 54px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  color: #ffffff;
  text-align: center;
  transform: translateX(-50%) rotate(-8deg);
  box-shadow: 0 6px 14px rgba(47, 110, 150, 0.2);
}

.balloon.special-bonus .balloon-badge {
  background: linear-gradient(180deg, #ffb648 0%, #ff7f24 100%);
}

.balloon.special-penalty .balloon-badge {
  background: linear-gradient(180deg, #4f5d78 0%, #2a3550 100%);
}

.score-burst {
  position: absolute;
  z-index: 6;
  left: 0;
  top: 0;
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
  text-shadow: 0 6px 14px rgba(47, 110, 150, 0.22);
  animation: score-burst-rise 0.85s ease-out forwards;
}

.score-burst.positive {
  color: #ff7f24;
}

.score-burst.negative {
  color: #33415f;
}

.face-burst {
  position: absolute;
  z-index: 6;
  left: 0;
  top: 0;
  font-size: 44px;
  line-height: 1;
  pointer-events: none;
  filter: drop-shadow(0 10px 16px rgba(47, 110, 150, 0.22));
  animation: face-burst-rise 1.1s ease-out forwards;
}

.burst,
.burst-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  opacity: 0;
  pointer-events: none;
}

.burst {
  width: 14px;
  height: 14px;
  margin-left: -7px;
  margin-top: -7px;
  border-radius: 999px;
  background: radial-gradient(circle, #ffffff 0%, var(--balloon-glow) 45%, var(--balloon-main) 100%);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.16);
}

.burst-ring {
  width: 34px;
  height: 34px;
  margin-left: -17px;
  margin-top: -17px;
  border: 4px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
}

.burst-a {
  --dx: -72px;
  --dy: -34px;
}

.burst-b {
  --dx: -26px;
  --dy: -74px;
}

.burst-c {
  --dx: 32px;
  --dy: -68px;
}

.burst-d {
  --dx: 74px;
  --dy: -22px;
}

.burst-e {
  --dx: 70px;
  --dy: 30px;
}

.burst-f {
  --dx: 18px;
  --dy: 76px;
}

.burst-g {
  --dx: -34px;
  --dy: 66px;
}

.burst-h {
  --dx: -78px;
  --dy: 12px;
}

.balloon.popping {
  cursor: default;
}

.balloon.popping .balloon-art {
  animation: none;
}

.balloon.popping .balloon-body,
.balloon.popping .balloon-knot,
.balloon.popping .balloon-string {
  animation: balloon-pop 0.26s ease-out forwards;
}

.balloon.popping .burst {
  animation: burst-fly 0.26s ease-out forwards;
}

.balloon.popping .burst-ring {
  animation: ring-bloom 0.26s ease-out forwards;
}

@keyframes sway {
  0%,
  100% {
    transform: translateX(-10px) rotate(-4deg);
  }
  50% {
    transform: translateX(10px) rotate(4deg);
  }
}

@keyframes special-pulse {
  0%,
  100% {
    transform: scale(1);
    filter: saturate(1);
  }
  50% {
    transform: scale(1.08);
    filter: saturate(1.2);
  }
}

@keyframes warning-pulse {
  0%,
  100% {
    transform: scale(1);
    filter: contrast(1);
  }
  50% {
    transform: scale(1.1);
    filter: contrast(1.15);
  }
}

@keyframes balloon-pop {
  0% {
    opacity: 1;
    transform: scale(1);
    filter: brightness(1);
  }
  65% {
    opacity: 0.9;
    transform: scale(1.18);
    filter: brightness(1.15);
  }
  100% {
    opacity: 0;
    transform: scale(0.35);
    filter: brightness(1.35);
  }
}

@keyframes burst-fly {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.2);
  }
  25% {
    opacity: 1;
    transform: translate(calc(var(--dx) * 0.35), calc(var(--dy) * 0.35)) scale(0.95);
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(1.15);
  }
}

@keyframes ring-bloom {
  0% {
    opacity: 0;
    transform: scale(0.25);
  }
  20% {
    opacity: 0.95;
    transform: scale(0.75);
  }
  100% {
    opacity: 0;
    transform: scale(1.9);
  }
}

@keyframes score-burst-rise {
  0% {
    opacity: 0;
    transform: translate(-50%, 12px) scale(0.6);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -8px) scale(1.05);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -72px) scale(1.15);
  }
}

@keyframes face-burst-rise {
  0% {
    opacity: 0;
    transform: translate(-50%, 8px) scale(0.5) rotate(-12deg);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -10px) scale(1.05) rotate(8deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -112px) scale(1.2) rotate(-8deg);
  }
}

@media (max-width: 720px) {
  .top-hud {
    top: 12px;
    left: 12px;
    right: 12px;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .hud-panel {
    padding: 12px 14px;
  }

  .hud-panel-center {
    order: 1;
  }

  .hud-panel-left {
    order: 2;
  }

  .hud-panel-right {
    order: 3;
    justify-self: stretch;
  }

  .player-row {
    flex-direction: column;
    align-items: stretch;
  }

  .score-panel,
  .timer-panel {
    padding: 12px 14px;
  }

  .player-name {
    font-size: 16px;
  }

  .overlay-card {
    padding: 22px 18px 20px;
  }

  .leaderboard-card {
    width: min(360px, calc(100vw - 32px));
  }

  .restart-button {
    width: 100%;
  }

  .sun {
    top: 120px;
    right: 24px;
    width: 82px;
    height: 82px;
  }

  .cloud-right {
    right: 4%;
  }
}
