:root {
  --ink: #4a2c2a;
  --muted-ink: #7b5a50;
  --cream: #fff7e7;
  --cream-deep: #f4d9a5;
  --card: rgba(255, 251, 241, 0.9);
  --pink: #f6a9c7;
  --blue: #a9d9f2;
  --yellow: #ffe09a;
  --mint: #bfe8d8;
  --lavender: #d5c7f2;
  --brown: #986a55;
  --rose: #d96b91;
  --shadow: rgba(91, 55, 34, 0.14);
  --deep-shadow: rgba(91, 55, 34, 0.22);
  --focus: rgba(72, 145, 184, 0.42);
  --z-canvas: 2;
  --z-decor: 1;
  --z-hud: 4;
  --z-screens: 6;
  --z-audio: 7;
  --z-celebration: 10;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  overscroll-behavior: none;
  color: var(--ink);
  font-family: Inter, ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  background:
    radial-gradient(circle at 18% 12%, rgba(246, 169, 199, 0.24) 0 58px, transparent 59px),
    radial-gradient(circle at 84% 18%, rgba(169, 217, 242, 0.26) 0 64px, transparent 65px),
    radial-gradient(circle at 22% 86%, rgba(191, 232, 216, 0.28) 0 72px, transparent 73px),
    linear-gradient(180deg, #fffaf0 0%, #fcecf1 48%, #eaf7f5 100%);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button,
a {
  font: inherit;
  -webkit-touch-callout: none;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible,
input:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 4px;
}

.app {
  position: relative;
  width: 100vw;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.seo-summary {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.wechat-share-image {
  position: fixed;
  left: 0;
  top: 0;
  width: 300px;
  height: 300px;
  object-fit: cover;
  opacity: 0.001;
  pointer-events: none;
  z-index: 0;
}

#gameCanvas {
  position: fixed;
  inset: 0;
  z-index: var(--z-canvas);
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: block;
  touch-action: none;
}

.party-decor {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: var(--z-decor);
}

.party-decor::before,
.party-decor::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.18;
  background-image:
    radial-gradient(circle, rgba(246, 169, 199, 0.62) 0 3px, transparent 4px),
    radial-gradient(circle, rgba(169, 217, 242, 0.58) 0 3px, transparent 4px),
    radial-gradient(circle, rgba(255, 224, 154, 0.68) 0 3px, transparent 4px);
  background-position: 14px 34px, 88px 112px, 46px 86px;
  background-size: 116px 116px, 148px 148px, 132px 132px;
}

.party-decor::after {
  opacity: 0.12;
  transform: rotate(8deg) scale(1.1);
  background-position: 62px 18px, 34px 92px, 110px 140px;
}

.garland {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  width: 138px;
  height: 44px;
  background:
    linear-gradient(135deg, transparent 47%, rgba(74, 44, 42, 0.28) 48% 52%, transparent 53%),
    linear-gradient(45deg, transparent 47%, rgba(74, 44, 42, 0.28) 48% 52%, transparent 53%);
}

.garland::before,
.garland::after {
  content: "";
  position: absolute;
  top: 20px;
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 24px solid var(--pink);
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.08));
}

.garland::before {
  left: 36px;
  border-top-color: var(--blue);
}

.garland::after {
  right: 34px;
  border-top-color: var(--yellow);
}

.garland-a {
  left: -18px;
  transform: rotate(-8deg);
}

.garland-b {
  right: -14px;
  transform: rotate(8deg);
}

.balloon {
  position: absolute;
  width: 42px;
  height: 54px;
  border-radius: 52% 52% 48% 48%;
  box-shadow: inset -9px -10px 0 rgba(91, 55, 34, 0.08), 0 12px 24px rgba(91, 55, 34, 0.1);
  animation: floaty 4s ease-in-out infinite;
}

.balloon::after {
  content: "";
  position: absolute;
  left: 18px;
  bottom: -30px;
  width: 1px;
  height: 34px;
  background: rgba(74, 44, 42, 0.28);
}

.balloon-pink {
  left: 7vw;
  top: 18vh;
  background: var(--pink);
}

.balloon-blue {
  right: 8vw;
  top: 20vh;
  background: var(--blue);
  animation-delay: -1.4s;
}

.balloon-yellow {
  right: 8vw;
  bottom: 10vh;
  background: var(--yellow);
  animation-delay: -2.2s;
}

.balloon-mint {
  left: 24vw;
  bottom: 11vh;
  width: 34px;
  height: 45px;
  background: var(--mint);
  animation-delay: -3s;
}

.star {
  position: absolute;
  color: #ffc445;
  font-size: 24px;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.06);
  animation: twinkle 1.5s ease-in-out infinite;
}

.star-a {
  left: 18vw;
  top: 10vh;
}

.star-b {
  right: 24vw;
  top: 12vh;
  animation-delay: -0.6s;
}

.star-c {
  left: 52vw;
  bottom: 18vh;
  color: #ff8fbe;
  font-size: 20px;
  animation-delay: -1s;
}

.candy {
  position: absolute;
  width: 36px;
  height: 18px;
  border-radius: 999px;
  background: repeating-linear-gradient(90deg, #fff 0 7px, #ff74a8 7px 14px);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.06);
}

.candy-a {
  left: 9vw;
  bottom: 18vh;
  transform: rotate(18deg);
}

.candy-b {
  right: 8vw;
  top: 42vh;
  transform: rotate(-22deg);
}

.candy-c {
  left: 44vw;
  top: 17vh;
  width: 30px;
  transform: rotate(-12deg);
  background: repeating-linear-gradient(90deg, #fff 0 6px, #8fd7ff 6px 12px);
}

.party-hat {
  position: absolute;
  width: 0;
  height: 0;
  border-left: 22px solid transparent;
  border-right: 22px solid transparent;
  border-bottom: 62px solid #cdb7ff;
  filter: drop-shadow(0 8px 0 rgba(91, 55, 34, 0.08));
  animation: bob 4.8s ease-in-out infinite;
}

.party-hat::before {
  content: "";
  position: absolute;
  left: -18px;
  top: 22px;
  width: 36px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 15px 0 rgba(255, 255, 255, 0.72);
}

.party-hat::after {
  content: "";
  position: absolute;
  left: -7px;
  top: 58px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffc445;
}

.hat-a {
  left: 5vw;
  top: 56vh;
  transform: rotate(-14deg);
}

.hat-b {
  right: 5vw;
  bottom: 27vh;
  border-bottom-color: #ff9ec9;
  transform: rotate(15deg) scale(0.82);
  animation-delay: -1.7s;
}

.gift {
  position: absolute;
  width: 48px;
  height: 42px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent 38%, rgba(255, 255, 255, 0.72) 39% 59%, transparent 60%),
    linear-gradient(180deg, transparent 34%, rgba(255, 255, 255, 0.72) 35% 53%, transparent 54%),
    #8fd7ff;
  box-shadow: 0 8px 0 rgba(91, 55, 34, 0.08);
  animation: bob 5.4s ease-in-out infinite;
}

.gift::before,
.gift::after {
  content: "";
  position: absolute;
  top: -16px;
  width: 20px;
  height: 18px;
  border: 5px solid #ff74a8;
  border-radius: 50% 50% 4px 50%;
}

.gift::before {
  left: 5px;
  transform: rotate(22deg);
}

.gift::after {
  right: 5px;
  transform: rotate(-68deg);
}

.gift-a {
  left: 5vw;
  bottom: 9vh;
}

.audio-controls {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  bottom: auto;
  left: max(14px, env(safe-area-inset-left));
  right: auto;
  z-index: var(--z-audio);
  display: flex;
  pointer-events: auto;
}

.app.game-active .audio-controls {
  top: auto;
  left: max(14px, env(safe-area-inset-left));
  bottom: max(12px, env(safe-area-inset-bottom));
}

.icon-toggle {
  width: 48px;
  min-width: 48px;
  height: 48px;
  min-height: 48px;
  border: 1px solid rgba(74, 44, 42, 0.1);
  border-radius: 50%;
  padding: 0;
  color: var(--ink);
  background: rgba(255, 251, 241, 0.82);
  box-shadow: 0 10px 24px rgba(91, 55, 34, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.92);
  font-size: 1.05rem;
  font-weight: 900;
  cursor: pointer;
  backdrop-filter: blur(12px);
}

.icon-toggle[aria-pressed="false"] {
  color: var(--muted-ink);
  background: rgba(255, 255, 255, 0.56);
}

.gift-b {
  right: 28vw;
  top: 9vh;
  width: 38px;
  height: 34px;
  background:
    linear-gradient(90deg, transparent 38%, rgba(255, 255, 255, 0.72) 39% 59%, transparent 60%),
    linear-gradient(180deg, transparent 34%, rgba(255, 255, 255, 0.72) 35% 53%, transparent 54%),
    #ffd86d;
  transform: rotate(10deg);
  animation-delay: -2s;
}

.lollipop {
  position: absolute;
  width: 36px;
  height: 36px;
  border: 4px solid #fff;
  border-radius: 50%;
  background: conic-gradient(#ff74a8 0 25%, #fff0a8 0 50%, #8fd7ff 0 75%, #95e6c8 0);
  box-shadow: 0 8px 0 rgba(91, 55, 34, 0.08);
  animation: spinFloat 7s ease-in-out infinite;
}

.lollipop::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 31px;
  width: 5px;
  height: 38px;
  border-radius: 999px;
  background: #9b6548;
  transform: translateX(-50%);
}

.lollipop-a {
  right: 4vw;
  top: 58vh;
}

.lollipop-b {
  left: 31vw;
  top: 8vh;
  width: 28px;
  height: 28px;
  animation-delay: -2.8s;
}

.cloud {
  position: absolute;
  width: 78px;
  height: 30px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: 0 8px 18px rgba(91, 55, 34, 0.05);
  animation: cloudDrift 9s ease-in-out infinite;
}

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

.cloud::before {
  left: 13px;
  width: 30px;
  height: 30px;
}

.cloud::after {
  right: 13px;
  width: 38px;
  height: 38px;
}

.cloud-a {
  left: 11vw;
  top: 32vh;
}

.cloud-b {
  right: 17vw;
  bottom: 8vh;
  transform: scale(0.78);
  animation-delay: -3.5s;
}

.screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding:
    calc(18px + env(safe-area-inset-top))
    calc(18px + env(safe-area-inset-right))
    calc(18px + env(safe-area-inset-bottom))
    calc(18px + env(safe-area-inset-left));
  pointer-events: none;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 220ms ease, transform 220ms ease;
  z-index: var(--z-screens);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overflow: hidden;
}

.screen-visible {
  pointer-events: auto;
  opacity: 1;
  transform: translateY(0);
}

.panel {
  width: min(92vw, 540px);
  padding: clamp(24px, 7vw, 42px);
  border: 1px solid rgba(74, 44, 42, 0.1);
  border-radius: 34px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.72), rgba(255, 247, 231, 0.92)),
    var(--card);
  box-shadow:
    0 28px 70px var(--shadow),
    0 10px 0 rgba(255, 255, 255, 0.36) inset,
    0 -8px 18px rgba(196, 144, 103, 0.07) inset;
  text-align: center;
  backdrop-filter: blur(8px);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  max-height: calc(100dvh - 36px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.start-panel,
.invite-panel {
  animation: popIn 420ms cubic-bezier(0.2, 1.25, 0.34, 1) both;
}

.start-panel {
  position: relative;
  display: grid;
  align-content: center;
  gap: clamp(14px, 2.8vh, 22px);
  overflow: hidden;
  min-height: clamp(500px, 70dvh, 650px);
  padding-top: clamp(54px, 10vh, 82px);
  padding-bottom: clamp(54px, 10vh, 82px);
}

.start-panel::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 16px;
  width: min(68vw, 280px);
  height: min(68vw, 280px);
  border-radius: 50%;
  background:
    radial-gradient(circle at 42% 35%, rgba(255, 255, 255, 0.86) 0 18%, transparent 19%),
    radial-gradient(circle at 50% 56%, rgba(246, 169, 199, 0.44) 0 38%, rgba(169, 217, 242, 0.26) 39% 55%, transparent 56%);
  opacity: 0.58;
  transform: translateX(-50%);
}

.start-panel > * {
  position: relative;
}

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

h1,
h2 {
  margin: 0;
  color: var(--ink);
  line-height: 0.98;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(3rem, 15vw, 5.4rem);
}

.game-title {
  display: grid;
  gap: 6px;
  justify-items: center;
  font-size: clamp(2.65rem, 13.2vw, 5rem);
  line-height: 0.88;
  text-align: center;
  text-wrap: balance;
  text-shadow:
    0 3px 0 rgba(255, 255, 255, 0.92),
    0 12px 28px rgba(91, 55, 34, 0.14);
}

.game-title span {
  display: block;
  white-space: nowrap;
}

.game-title span:first-child,
.game-title span:nth-child(3) {
  color: var(--muted-ink);
  font-size: 0.38em;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.game-title span:nth-child(2) {
  color: var(--rose);
  font-size: 1.05em;
}

h2 {
  font-size: clamp(2.1rem, 10vw, 4rem);
}

.subtitle,
.panel p {
  font-size: clamp(1rem, 4.4vw, 1.28rem);
  line-height: 1.42;
}

.subtitle {
  margin: 0 auto clamp(16px, 2.8vh, 26px);
  max-width: 18rem;
  color: var(--muted-ink);
  font-weight: 800;
}

.primary-button,
.secondary-button {
  min-height: 52px;
  min-width: 168px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 24px;
  padding: 14px 18px;
  color: #fff;
  background: linear-gradient(180deg, #f8a2c0, #dc638f);
  box-shadow:
    0 8px 0 #b95474,
    0 16px 30px rgba(169, 46, 96, 0.22),
    inset 0 2px 0 rgba(255, 255, 255, 0.42);
  font-weight: 1000;
  letter-spacing: 0;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

.secondary-button {
  color: #5b342f;
  background: linear-gradient(180deg, #fff, #ffeec0);
  box-shadow:
    0 6px 0 #e1c171,
    0 12px 22px rgba(132, 87, 31, 0.14),
    inset 0 2px 0 rgba(255, 255, 255, 0.7);
}

.primary-button:active,
.secondary-button:active,
.cake-button:active {
  transform: translateY(5px) scale(0.98);
  box-shadow: 0 4px 0 rgba(99, 54, 56, 0.45), 0 8px 16px rgba(132, 87, 31, 0.18);
}

.hud {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: 0;
  right: 0;
  z-index: var(--z-hud);
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  pointer-events: none;
}

.pill {
  min-width: 104px;
  padding: 10px 14px;
  border-radius: 999px;
  color: #57312f;
  background: rgba(255, 251, 241, 0.82);
  box-shadow: 0 10px 24px rgba(91, 55, 34, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.84);
  font-weight: 1000;
  text-align: center;
}

.feedback {
  position: absolute;
  top: calc(100% + 12px);
  left: 50%;
  width: min(86vw, 360px);
  transform: translateX(-50%) scale(0.8);
  color: var(--rose);
  font-size: clamp(1.75rem, 9vw, 3.2rem);
  font-weight: 1000;
  text-align: center;
  text-shadow: 0 4px 0 #fff, 0 10px 24px rgba(91, 55, 34, 0.18);
  opacity: 0;
}

.feedback.show {
  animation: feedbackPop 900ms ease both;
}

.cake-button {
  width: min(70vw, 250px);
  aspect-ratio: 1;
  margin-top: 6px;
  border: 0;
  border-radius: 34%;
  background:
    radial-gradient(circle at 38% 28%, rgba(255, 255, 255, 0.9) 0 18%, transparent 19%),
    radial-gradient(circle, #fffdf2, #ffe3ef);
  box-shadow:
    0 12px 0 #e8a1be,
    0 24px 42px rgba(141, 62, 95, 0.2),
    inset 0 4px 0 rgba(255, 255, 255, 0.72);
  cursor: pointer;
  touch-action: manipulation;
}

.mini-cake {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}

.mini-layer {
  position: absolute;
  left: 50%;
  height: 32px;
  border-radius: 18px 18px 12px 12px;
  transform: translateX(-50%);
  box-shadow: inset 0 -8px 0 rgba(91, 55, 34, 0.08), inset 0 5px 0 rgba(255, 255, 255, 0.35);
}

.mini-layer.top {
  top: 78px;
  width: 118px;
  background: linear-gradient(180deg, #ffc4d8, #f09bbc);
}

.mini-layer.mid {
  top: 109px;
  width: 150px;
  background: linear-gradient(180deg, #fff6c9, #f3da89);
}

.mini-layer.base {
  top: 140px;
  width: 180px;
  background: linear-gradient(180deg, #c4e8fa, #94d5ee);
}

.mini-candles {
  position: absolute;
  top: 48px;
  left: 50%;
  display: flex;
  gap: 15px;
  transform: translateX(-50%);
}

.mini-candles i {
  position: relative;
  display: block;
  width: 8px;
  height: 34px;
  border-radius: 999px;
  background: repeating-linear-gradient(180deg, #fff 0 7px, #ff679b 7px 14px);
}

.mini-candles i::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -15px;
  width: 14px;
  height: 18px;
  border-radius: 50% 50% 45% 45%;
  background: #ffc638;
  transform: translateX(-50%);
  box-shadow: 0 0 18px rgba(255, 198, 56, 0.78);
  animation: flame 360ms ease-in-out infinite alternate;
}

.cake-button.blown .mini-candles i::before {
  opacity: 0;
  transform: translateX(-50%) scale(0.2);
}

.blow-meter {
  height: 12px;
  width: min(76vw, 280px);
  margin: 22px auto 0;
  border-radius: 999px;
  background: rgba(91, 55, 34, 0.14);
  overflow: hidden;
}

.blow-meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--mint), var(--yellow));
  transition: width 120ms ease;
}

.invite-details {
  display: grid;
  gap: 12px;
  margin: 22px 0;
  padding: 14px;
  border: 1px solid rgba(74, 44, 42, 0.08);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.56);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.86);
}

.detail-block {
  padding: 12px;
  border-radius: 20px;
  background: rgba(255, 247, 231, 0.62);
}

.invite-details p {
  margin: 6px 0;
  font-weight: 900;
}

.detail-label {
  margin-top: 14px;
  color: var(--rose);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.invite-details .detail-main {
  margin-top: 2px;
  color: #593231;
  font-size: clamp(1.35rem, 6vw, 2rem);
  line-height: 1.1;
}

.invite-details .detail-address {
  margin-top: 2px;
  color: #2c6f8f;
  font-size: clamp(1.05rem, 4.7vw, 1.35rem);
  line-height: 1.28;
}

.button-row {
  display: grid;
  gap: 12px;
}

.score-actions .primary-button,
.score-actions .secondary-button,
.invite-actions .secondary-button {
  min-width: 0;
}

.score-panel {
  display: grid;
  gap: 12px;
}

.score-summary {
  margin: 14px 0 18px;
  font-weight: 900;
  line-height: 1.5;
}

.leaderboard-card {
  margin-top: 0;
  padding: 12px 14px;
  border: 1px solid rgba(74, 44, 42, 0.08);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.38);
  color: rgba(74, 44, 42, 0.78);
  text-align: left;
}

.score-form {
  display: grid;
  gap: 8px;
  margin: 0 auto 12px;
  text-align: left;
}

.score-form label,
.leaderboard h3 {
  color: #b4667d;
  font-size: 0.8rem;
  font-weight: 1000;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.score-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.score-form input {
  min-width: 0;
  height: 54px;
  border: 2px solid rgba(74, 44, 42, 0.14);
  border-radius: 18px;
  padding: 0 16px;
  color: #593231;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 3px 0 rgba(91, 55, 34, 0.05);
  font-size: 1.1rem;
  font-weight: 900;
}

.compact-button {
  min-width: 112px;
  min-height: 54px;
  padding: 12px 16px;
}

.score-message {
  min-height: 1.3em;
  margin: 0;
  color: #2c6f8f;
  font-size: 0.95rem;
  font-weight: 900;
  text-align: center;
}

.leaderboard {
  margin: 14px 0 0;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.42);
  text-align: left;
}

.leaderboard h3 {
  margin: 0 0 10px;
}

.leaderboard ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 188px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.leaderboard li {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 14px;
  background: rgba(255, 244, 214, 0.72);
  color: #593231;
  font-weight: 900;
}

.leaderboard .rank {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #fff;
  background: #e94889;
  font-size: 0.88rem;
}

.leaderboard .score {
  color: #2c6f8f;
}

.leaderboard-empty {
  display: block;
  margin: 0;
  color: rgba(74, 44, 42, 0.72);
  font-weight: 900;
  text-align: center;
}

.score-actions {
  margin-top: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.invite-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.invite-actions > :last-child {
  grid-column: 1 / -1;
}

.invite-message {
  min-height: 1.3em;
  margin: 12px 0 0;
  color: #2c6f8f;
  font-size: 0.95rem;
  font-weight: 900;
}

.confetti {
  position: fixed;
  top: -24px;
  z-index: calc(var(--z-celebration) + 1);
  width: 10px;
  height: 18px;
  border-radius: 3px;
  pointer-events: none;
  animation: confettiFall var(--fall-time, 1800ms) linear forwards;
}

.celebration-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-celebration);
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 46%, rgba(255, 255, 255, 0.72), transparent 34%),
    radial-gradient(circle at 20% 80%, rgba(246, 169, 199, 0.28), transparent 32%),
    radial-gradient(circle at 84% 20%, rgba(169, 217, 242, 0.28), transparent 32%),
    rgba(255, 247, 231, 0.34);
  transition: opacity 180ms ease;
}

.celebration-overlay.show {
  opacity: 1;
}

.celebration-glow {
  width: min(72vw, 420px);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.9) 0 22%, rgba(255, 224, 154, 0.52) 23% 42%, rgba(246, 169, 199, 0.24) 43% 62%, transparent 63%);
  filter: blur(1px);
  transform: scale(0.72);
}

.celebration-overlay.show .celebration-glow {
  animation: celebrationPulse 1150ms ease-out both;
}

.cannon-piece {
  position: fixed;
  left: var(--start-x);
  bottom: calc(-22px + env(safe-area-inset-bottom));
  z-index: calc(var(--z-celebration) + 2);
  width: var(--piece-size, 10px);
  height: calc(var(--piece-size, 10px) * 1.35);
  border-radius: 4px;
  background: var(--piece-color);
  pointer-events: none;
  animation: cannonBurst var(--burst-time, 1200ms) cubic-bezier(0.18, 0.8, 0.32, 1) forwards;
}

@keyframes floaty {
  50% {
    transform: translateY(-14px) rotate(3deg);
  }
}

@keyframes twinkle {
  50% {
    transform: scale(1.25) rotate(12deg);
    opacity: 0.64;
  }
}

@keyframes bob {
  50% {
    translate: 0 -12px;
  }
}

@keyframes spinFloat {
  50% {
    translate: 0 -10px;
    rotate: 12deg;
  }
}

@keyframes cloudDrift {
  50% {
    translate: 16px -6px;
  }
}

@keyframes popIn {
  from {
    transform: scale(0.88);
    opacity: 0;
  }
}

@keyframes feedbackPop {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(12px) scale(0.7);
  }
  24%,
  70% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-12px) scale(0.9);
  }
}

@keyframes flame {
  from {
    transform: translateX(-50%) scale(0.86) rotate(-5deg);
  }
  to {
    transform: translateX(-50%) scale(1.08) rotate(6deg);
  }
}

@keyframes confettiFall {
  to {
    transform: translate3d(var(--drift, 0), 110vh, 0) rotate(720deg);
    opacity: 0.2;
  }
}

@keyframes celebrationPulse {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  42% {
    opacity: 1;
    transform: scale(1.04);
  }
  100% {
    opacity: 0.3;
    transform: scale(1.34);
  }
}

@keyframes cannonBurst {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) rotate(0deg) scale(0.7);
  }
  12% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--burst-x), var(--burst-y), 0) rotate(var(--burst-rotate)) scale(1);
  }
}

@media (min-width: 720px) {
  .button-row {
    grid-template-columns: repeat(3, 1fr);
  }

  .score-actions {
    grid-template-columns: repeat(2, 1fr);
  }

  .primary-button,
  .secondary-button {
    min-width: 0;
  }
}

@media (max-width: 430px) {
  .icon-toggle {
    width: 46px;
    min-width: 46px;
    height: 46px;
    min-height: 46px;
  }

  .screen {
    padding-inline: calc(12px + env(safe-area-inset-left));
    padding-right: calc(12px + env(safe-area-inset-right));
  }

  .panel {
    width: min(94vw, 520px);
    border-radius: 28px;
  }

  .pill {
    min-width: 96px;
    padding-inline: 10px;
    font-size: 0.92rem;
  }

  .score-input-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }
}

@media (max-height: 700px) {
  .screen {
    place-items: center;
    padding-top: calc(10px + env(safe-area-inset-top));
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }

  .panel {
    padding: 16px;
    max-height: calc(100dvh - 20px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  h1 {
    font-size: clamp(2.6rem, 12vw, 4.6rem);
  }

  .game-title {
    font-size: clamp(2.3rem, 10vw, 3.8rem);
    line-height: 0.88;
  }

  h2 {
    font-size: clamp(1.65rem, 7vw, 2.8rem);
  }

  .subtitle,
  .panel p {
    font-size: 0.95rem;
  }

  .subtitle {
    margin: 10px auto 16px;
  }

  .start-panel {
    min-height: min(560px, calc(100dvh - 20px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
    gap: 10px;
    padding-top: 28px;
    padding-bottom: 28px;
  }

  .leaderboard-card {
    padding: 10px;
  }

  .leaderboard {
    margin-top: 8px;
    padding: 8px;
  }

  .leaderboard ol {
    gap: 5px;
    max-height: 108px;
  }

  .leaderboard li {
    min-height: 30px;
    padding: 4px 8px;
  }

  .cake-button {
    width: min(46vh, 62vw, 210px);
  }

  .mini-layer.top {
    top: 30%;
    width: 45%;
  }

  .mini-layer.mid {
    top: 42%;
    width: 58%;
  }

  .mini-layer.base {
    top: 54%;
    width: 70%;
  }

  .mini-candles {
    top: 18%;
  }

  .blow-meter {
    margin-top: 14px;
  }

  .invite-details {
    margin: 14px 0;
    padding: 12px;
  }

  .button-row {
    gap: 8px;
  }

  .primary-button,
  .secondary-button {
    min-height: 48px;
    padding: 11px 14px;
  }

  .leaderboard-card {
    margin-top: 10px;
  }
}

@media (max-width: 520px), (max-height: 700px) {
  .candy,
  .party-hat,
  .gift,
  .lollipop,
  .cloud,
  .star-c,
  .balloon-mint,
  .gift-b,
  .lollipop-b {
    display: none;
  }

  .balloon {
    opacity: 0.58;
    transform: scale(0.82);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }

  .party-decor::before,
  .party-decor::after {
    opacity: 0.08;
  }

  .balloon,
  .star,
  .gift,
  .cloud {
    animation: none;
  }
}
