.score-hud .new-player-hud {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 44px;
  padding: 5px 9px;
  border: 1px solid #d8ac75;
  border-radius: 8px;
  color: #fff4df;
  background: #482e62;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  touch-action: manipulation;
}

.score-hud .new-player-hud:hover { background: #6c4b8d; }
.score-hud .new-player-hud > [data-icon] { color: #ffdb9e; }

.dialog-celebration {
  --celebration-purple: #3d1f5c;
  --celebration-gold: #ffd98d;
  --celebration-cream: #fff6e1;
  width: min(90vw, 750px);
  max-height: min(80dvh, 620px);
  overflow: auto;
  border: 1px solid #82689d;
  border-radius: 17px;
  color: var(--celebration-purple);
  background: #402956;
  box-shadow: 0 23px 86px #180d23a9;
}

.dialog-celebration .close {
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  color: #fff2d4;
  background: #43285f;
  border-color: #a38cbb;
}

.dialog-celebration .close:hover { background: #6a468f; }

.dialog-celebration .celebration-sheet {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
}

.dialog-celebration .celebration-hero {
  position: relative;
  isolation: isolate;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 11px;
  min-width: 0;
  overflow: hidden;
  padding: 25px 21px 28px;
  color: var(--celebration-cream);
  text-align: center;
  background:
    radial-gradient(ellipse at 50% 15%, #794fa4 0%, transparent 64%),
    repeating-linear-gradient(140deg, #ffefb707 0 1px, transparent 1px 5px),
    linear-gradient(145deg, #4b2d6a, #301b45 90%);
}

.dialog-celebration .celebration-hero::after {
  content: "";
  position: absolute;
  inset: 9px;
  z-index: -1;
  border: 1px solid #f6ca806e;
  border-radius: 10px 10px 5px 5px;
  pointer-events: none;
}

.dialog-celebration .celebration-emblem {
  position: relative;
  display: grid;
  place-items: center;
  width: 110px;
  height: 110px;
  color: #ffe398;
  filter: drop-shadow(0 5px 0 #2e1b41aa);
  animation: celebration-seal-in .72s cubic-bezier(.2,.87,.33,1.09) both;
}

.dialog-celebration .celebration-emblem > svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.dialog-celebration .celebration-emblem > span [data-icon] { width: 42px; height: 42px; }

.dialog-celebration .celebration-title {
  max-width: 100%;
  padding-inline: 5px;
  animation: celebration-heading-in .65s .12s cubic-bezier(.2,.7,.31,1) both;
}

.dialog-celebration .celebration-title > p {
  margin: 0 0 7px;
  color: #ffe0ae;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .105em;
  text-transform: uppercase;
}

.dialog-celebration .celebration-title > h2 {
  margin: 0;
  color: #fff4d8;
  font: 700 clamp(41px, 6.5vw, 72px)/.99 var(--heading-font);
  letter-spacing: -.047em;
  text-wrap: balance;
  text-shadow: 0 3px #321c475c;
}

.dialog-celebration .celebration-achievement {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin: 0;
  color: #fff2d9;
  font-size: 15px;
  font-weight: 745;
  line-height: 1.25;
}

.dialog-celebration .celebration-achievement > [data-icon] { color: var(--celebration-gold); }

.dialog-celebration .celebration-score {
  display: grid;
  gap: 2px;
  min-width: 146px;
  margin-top: 7px;
  padding: 8px 14px 9px;
  border: 1px solid #f6cb82;
  border-radius: 8px;
  color: #5b291e;
  background: linear-gradient(147deg, #fff0bc, #eeba74);
  box-shadow: 0 3px #2c1841, inset 0 0 0 2px #fff5d249;
}

.dialog-celebration .celebration-score > strong {
  font: 700 clamp(29px, 5vw, 45px)/.94 var(--heading-font);
  font-variant-numeric: tabular-nums;
}

.dialog-celebration .celebration-score > span { font-size: 13px; font-weight: 800; }

.dialog-celebration .celebration-confetti {
  position: absolute;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  pointer-events: none;
}

.dialog-celebration .celebration-confetti > i {
  position: absolute;
  top: var(--y);
  left: var(--x);
  width: 6px;
  height: 12px;
  border-radius: 1px;
  background: var(--tint);
  transform: rotate(var(--spin));
  opacity: .44;
  animation: celebration-scatter 1.15s var(--wait) cubic-bezier(.16,.64,.41,1) both;
}

.dialog-celebration .celebration-confetti > i:nth-child(3n) { width: 8px; height: 8px; border-radius: 50%; }
.dialog-celebration .celebration-confetti > i:nth-child(4n) { height: 7px; }

.dialog-celebration .celebration-claim {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 10px;
  min-width: 0;
  padding: 24px 25px 20px;
  text-align: center;
  background:
    repeating-linear-gradient(126deg, transparent 0 9px, #866f9c0a 9px 10px, transparent 10px 17px),
    linear-gradient(142deg, #fffae9, #f3e0c3);
}

.dialog-celebration .celebration-claim > header { padding-inline: 14px; }
.dialog-celebration .celebration-claim h3 {
  margin: 0;
  color: var(--celebration-purple);
  font: 700 clamp(25px, 4.3vw, 35px)/1.06 var(--heading-font);
  letter-spacing: -.025em;
}

.dialog-celebration .celebration-claim > header p {
  margin-top: 5px;
  color: #65473d;
  font-size: 15px;
  line-height: 1.34;
}

.dialog-celebration .celebration-qr-wrap {
  width: min(100%, 252px);
  padding: 13px;
  border: 1px solid #b5937b;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 3px #b693773a;
}

.dialog-celebration #celebration-qr {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  background: #fff;
}

.dialog-celebration #celebration-qr > :is(svg, img, canvas) {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.dialog-celebration .celebration-qr-placeholder {
  position: relative;
  width: 62%;
  aspect-ratio: 1;
  border: 1px dashed #ddccb7;
  border-radius: 4px;
}

.dialog-celebration .celebration-qr-placeholder > span {
  position: absolute;
  inset: 8px auto auto 8px;
  width: 28%;
  aspect-ratio: 1;
  border: 4px solid #e8d6bb;
  border-radius: 2px;
}

.dialog-celebration .celebration-qr-placeholder > span:nth-child(2) { inset: 8px 8px auto auto; }
.dialog-celebration .celebration-qr-placeholder > span:nth-child(3) { inset: auto auto 8px 8px; }

.dialog-celebration .celebration-claim-link, .dialog-celebration #celebration-retry { min-height: 44px; }
.dialog-celebration #celebration-claim-status {
  margin: 0;
  color: #624438;
  font-size: 14px;
  font-weight: 675;
  line-height: 1.31;
  overflow-wrap: anywhere;
}

.dialog-celebration #celebration-claim-status:empty { display: none; }
.dialog-celebration .celebration-qr-wrap:has(#celebration-qr[hidden]) { display: none; }

.dialog-celebration .celebration-footer {
  display: flex;
  grid-column: 1 / -1;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
  padding: 9px 11px;
  border-top: 1px solid #9174ae;
  background: #3b2155;
}

.dialog-celebration .celebration-footer > button {
  min-height: 44px;
  color: #fce8cf;
  background: #51366d;
  border-color: #9680ac;
}

.dialog-celebration .celebration-footer > button:hover { background: #68468a; }

.dialog-celebration #celebration-new-player {
  color: #4c2324;
  background: #ffd98d;
  border-color: #fff0ba;
}

.dialog-celebration #celebration-new-player:hover { background: #ffe6a8; }

@keyframes celebration-heading-in {
  from { opacity: .32; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes celebration-seal-in {
  from { opacity: .5; transform: translateY(-8px) rotate(-14deg) scale(.79); }
  to { opacity: 1; transform: translateY(0) rotate(0) scale(1); }
}

@keyframes celebration-scatter {
  0% { opacity: 0; transform: translate(var(--from-x), var(--from-y)) rotate(0) scale(.53); }
  20% { opacity: .97; }
  66% { opacity: .83; transform: translate(0, -7px) rotate(var(--spin)) scale(1); }
  100% { opacity: .44; transform: translate(0, 0) rotate(var(--spin)) scale(1); }
}

@media (max-width: 780px) {
  .score-hud .player-name-wrap { display: none; }
  .score-hud .player-chip { padding: 4px; }
}

@media (min-width: 561px) and (max-width: 650px) {
  .map .controls-bar > span:nth-last-child(-n + 2) { display: none; }
}

@media (max-width: 560px) {
  .score-hud { gap: 4px; }
  .score-hud .collect-hud { gap: 3px; padding-inline: 6px; font-size: 13px; }
  .score-hud .new-player-hud { gap: 4px; padding-inline: 7px; font-size: 13px; }
}

@media (max-width: 355px) {
  .score-hud .new-player-hud > [data-icon] { display: none; }
}

@media (max-width: 620px) {
  .dialog-celebration { width: min(96vw, 450px); max-height: 94dvh; }
  .dialog-celebration .celebration-sheet { grid-template-columns: minmax(0, 1fr); }

  .dialog-celebration .celebration-hero {
    gap: 6px;
    padding: 17px 15px 16px;
  }

  .dialog-celebration .celebration-hero::after { inset: 6px; }
  .dialog-celebration .celebration-emblem { width: 64px; height: 64px; }
  .dialog-celebration .celebration-emblem > span [data-icon] { width: 25px; height: 25px; }
  .dialog-celebration .celebration-title > p { margin-bottom: 5px; font-size: 11px; }
  .dialog-celebration .celebration-title > h2 { font-size: clamp(33px, 9.8vw, 47px); }
  .dialog-celebration .celebration-achievement { font-size: 13px; }
  .dialog-celebration .celebration-score { display: flex; align-items: baseline; justify-content: center; gap: 6px; min-width: 0; margin-top: 3px; padding: 5px 9px; }
  .dialog-celebration .celebration-score > strong { font-size: 27px; }
  .dialog-celebration .celebration-score > span { font-size: 12px; }

  .dialog-celebration .celebration-claim { gap: 8px; padding: 14px 15px; }
  .dialog-celebration .celebration-claim > header { padding-inline: 0; }
  .dialog-celebration .celebration-claim > header p { font-size: 14px; }
  .dialog-celebration .celebration-qr-wrap { width: min(100%, 220px); padding: 11px; }
  .dialog-celebration .celebration-footer { padding: 7px 9px; }
  .dialog-celebration .celebration-footer > button { flex: 1 1 auto; padding-inline: 9px; font-size: 14px; }
}

.dialog-celebration:has(.has-gradebook) { width: min(95vw, 780px); max-height: min(90dvh, 690px); }
.dialog-celebration .has-gradebook { grid-template-columns: minmax(0, 1.22fr) minmax(0, 1fr); }
.dialog-celebration .has-gradebook .celebration-hero {
  grid-column: 1 / -1;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  justify-items: start;
  align-items: center;
  gap: 12px;
  padding: 13px 66px 15px 17px;
  text-align: left;
}
.dialog-celebration .has-gradebook .celebration-emblem { width: 64px; height: 64px; }
.dialog-celebration .has-gradebook .celebration-emblem > span [data-icon] { width: 26px; height: 26px; }
.dialog-celebration .has-gradebook .celebration-title { padding: 0; }
.dialog-celebration .has-gradebook .celebration-title > p { margin-bottom: 4px; font-size: 10px; }
.dialog-celebration .has-gradebook .celebration-title > h2 { font-size: clamp(27px, 4.5vw, 47px); line-height: 1.01; text-wrap: initial; }
.dialog-celebration .has-gradebook .celebration-achievement { display: none; }
.dialog-celebration .has-gradebook .celebration-score { min-width: 95px; margin: 0; padding: 5px 8px 6px; text-align: center; }
.dialog-celebration .has-gradebook .celebration-score > strong { font-size: 29px; }
.dialog-celebration .has-gradebook .celebration-score > span { font-size: 11px; }
.dialog-celebration .has-gradebook .celebration-footer { position: sticky; z-index: 2; bottom: 0; }

.tour-gradebook { min-width: 0; padding: 14px; border-right: 1px solid #d6bdad; background: #fff8e8; }
.tour-gradebook-header { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.tour-gradebook-header h3 { color: #3d2456; font: 700 clamp(25px, 3.4vw, 34px)/1.07 var(--heading-font); }
.tour-gradebook-name { margin-top: 3px; color: #6c4b6b; font-size: 13px; font-weight: 750; overflow-wrap: anywhere; }
.tour-gradebook-grade {
  min-width: 80px;
  display: grid;
  justify-items: center;
  padding: 5px 8px;
  border: 1px solid #b67c4d;
  border-radius: 8px;
  background: #ffe5a3;
  color: #532e43;
  box-shadow: 0 2px #e1ba7b;
}
.tour-gradebook-grade strong { font: 700 36px/.97 var(--heading-font); }
.tour-gradebook-grade span { color: #714547; font-size: 11px; font-weight: 800; white-space: nowrap; }
.tour-gradebook-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(66px, 100%), 1fr)); gap: 5px; margin: 11px 0 9px; }
.tour-gradebook-stats div { display: grid; align-content: start; gap: 2px; min-width: 0; padding: 6px; border-radius: 6px; background: #f0e6f7; }
.tour-gradebook-stats div:nth-child(2) { background: #e0f2e9; }
.tour-gradebook-stats div:nth-child(3) { background: #ffedc1; }
.tour-gradebook-stats div:nth-child(4) { background: #f9e5ed; }
.tour-gradebook-stats dt { color: #593c63; font-size: 10px; font-weight: 760; line-height: 1.15; }
.tour-gradebook-stats dd { margin: 0; color: #382347; font-size: 17px; font-weight: 850; line-height: 1.15; overflow-wrap: anywhere; }
.tour-gradebook-stats div:nth-child(4) dd { font-size: 13px; }
.tour-gradebook-insight { padding: 8px 10px; border: 1px solid #c3dace; border-left: 4px solid #4f8c77; border-radius: 7px; color: #244d4d; background: #e8f3e9; }
.tour-gradebook-insight h4 { display: flex; align-items: center; gap: 4px; margin: 0 0 3px; font-size: 14px; }
.tour-gradebook-insight small { font-size: 11px; font-weight: 800; }
.tour-gradebook-insight p { margin-top: 3px; color: #2e4f44; font-size: 13px; line-height: 1.29; }
.tour-gradebook-details { margin-top: 7px; border: 1px solid #d1bbda; border-radius: 7px; color: #4c2b66; background: #fbf0fb; }
.tour-gradebook-details > summary { display: flex; justify-content: space-between; align-items: center; gap: 5px; min-height: 42px; padding: 5px 9px; list-style: none; font-size: 13px; font-weight: 850; cursor: pointer; }
.tour-gradebook-details > summary::-webkit-details-marker { display: none; }
.tour-gradebook-details > summary > span::before { content: '+'; margin-right: 7px; color: #78598e; }
.tour-gradebook-details[open] > summary > span::before { content: '−'; }
.tour-gradebook-details > summary b { padding: 2px 5px; border-radius: 4px; color: #714e8b; background: #ecdcf2; }
.tour-gradebook-details > h4 { padding: 5px 9px 2px; font-size: 12px; }
.tour-rounds { display: grid; gap: 5px; padding: 5px 8px 8px; list-style-type: none; }
.tour-round { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 3px 8px; min-width: 0; padding: 6px 7px; border-radius: 5px; background: #fffbf4; }
.tour-round strong, .tour-round small { display: block; overflow-wrap: anywhere; }
.tour-round strong { font-size: 13px; }
.tour-round small { color: #705c70; font-size: 11px; }
.tour-round p { grid-column: 1 / -1; color: #4c4956; font-size: 12px; line-height: 1.25; }
.tour-round-score { color: #6c417a; white-space: nowrap; font-size: 11px; }
.tour-round-outcome { grid-column: 1 / -1; color: #426654; font-size: 11px; font-weight: 750; }
.tour-gradebook-rule { margin-top: 8px; color: #644d5b; font-size: 11px; line-height: 1.3; }

.dialog-celebration .has-gradebook .celebration-claim { align-content: start; gap: 6px; padding: 12px; }
.dialog-celebration .has-gradebook .celebration-claim h3 { font-size: clamp(23px, 3.3vw, 30px); }
.dialog-celebration .has-gradebook .celebration-claim > header { padding-inline: 0; }
.dialog-celebration .has-gradebook .celebration-claim > header p { margin-top: 3px; font-size: 13px; }
.dialog-celebration .has-gradebook .celebration-qr-wrap { width: min(100%, 158px); padding: 7px; }
.dialog-celebration .has-gradebook #celebration-claim-status { font-size: 12px; }
.dialog-celebration .has-gradebook #celebration-board { min-height: 44px; }
.tour-standings { width: 100%; display: grid; gap: 3px; margin: 0; padding: 0; list-style-type: none; text-align: left; }
.tour-standings li { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto auto; align-items: center; gap: 5px; min-height: 27px; padding: 2px 5px; border: 1px solid #e1c7b1; border-radius: 5px; color: #543751; background: #fff9ea; }
.tour-standings li.is-player { border-color: #a2c5b4; background: #e2f3eb; }
.tour-standing-rank { align-self: center; text-align: center; font-size: 11px; }
.tour-standings strong { overflow: hidden; color: #442c53; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.tour-standings small { padding: 1px 3px; border-radius: 3px; color: #406d5d; background: #f2fbf1; font-size: 10px; font-weight: 770; }
.tour-standings b { grid-column: 4; white-space: nowrap; font-size: 12px; }
.tour-standings-empty { margin: 1px 0; color: #6a5165; font-size: 12px; }

@media (max-width: 620px) {
  .dialog-celebration:has(.has-gradebook) { width: min(96vw, 470px); max-height: 93dvh; }
  .dialog-celebration .has-gradebook { grid-template-columns: minmax(0, 1fr); }
  .dialog-celebration .has-gradebook .celebration-hero { grid-template-columns: 44px minmax(0, 1fr); gap: 4px 8px; padding: 11px 53px 12px 12px; }
  .dialog-celebration .has-gradebook .celebration-emblem { grid-row: span 2; width: 44px; height: 44px; }
  .dialog-celebration .has-gradebook .celebration-emblem > span [data-icon] { width: 19px; height: 19px; }
  .dialog-celebration .has-gradebook .celebration-score { grid-column: 2; min-width: 0; padding: 3px 7px; }
  .dialog-celebration .has-gradebook .celebration-score > strong { font-size: 21px; }
  .tour-gradebook { padding: 10px; border-right: 0; border-bottom: 1px solid #d6bdad; }
  .dialog-celebration .has-gradebook .celebration-claim { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto auto minmax(0, auto) minmax(0, auto) minmax(0, auto); align-items: center; }
  .dialog-celebration .has-gradebook .celebration-claim > :is(header, .tour-standings, .tour-standings-empty) { grid-column: 1 / -1; }
  .dialog-celebration .has-gradebook .celebration-qr-wrap { grid-column: 1; grid-row: 3 / span 3; }
  .dialog-celebration .has-gradebook .celebration-claim > :is(#celebration-claim-status, #claim-score-link, #celebration-retry, #celebration-board) { grid-column: 2; }
  .dialog-celebration .has-gradebook .celebration-claim:has(#celebration-qr[hidden]) { grid-template-columns: minmax(0, 1fr); }
  .dialog-celebration .has-gradebook .celebration-claim:has(#celebration-qr[hidden]) > :is(#celebration-claim-status, #claim-score-link, #celebration-retry, #celebration-board) { grid-column: 1; }
  .dialog-celebration .has-gradebook .celebration-claim .pill { padding-inline: 7px; font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .dialog-celebration .celebration-title,
  .dialog-celebration .celebration-emblem,
  .dialog-celebration .celebration-confetti > i { animation: none; }
}
