/* Win screen: champion medallion on a sunburst, colour ribbon title, runner-up rows, prize chips.
   --cc / --tc (winner colour and its text colour) are set on #win .card by showWin() in js/05-gameplay.js. */
/* margin:auto centres the card but, unlike place-items, never pushes its top out of reach when the screen is short. */
#win {
  place-items: start center;
}
#win .card {
  margin: auto;
  --ink: #343363;
  --soft: #6b64a8;
  position: relative;
  width: min(100%, 440px);
  padding: 0 18px 20px;
  overflow: hidden;
  background:
    radial-gradient(ellipse 120% 46% at 50% 0%, color-mix(in srgb, var(--cc) 30%, #fff) 0%, rgba(255, 255, 255, 0) 100%),
    #fbfaff;
  border: 0;
  border-radius: 34px;
  box-shadow:
    0 12px 0 color-mix(in srgb, var(--cc) 38%, #9a9ed0),
    0 30px 70px rgba(30, 20, 90, 0.45),
    inset 0 0 0 3px #fff;
}

/* ---- hero: sunburst, medallion, crown, sparkles */
.win-hero {
  position: relative;
  height: 214px;
  margin: 0 -18px;
  padding-top: 26px;
  box-sizing: border-box;
  display: grid;
  place-items: center;
}
.win-rays {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 520px;
  height: 520px;
  margin: -260px 0 0 -260px;
  background: repeating-conic-gradient(
    from 0deg,
    color-mix(in srgb, var(--cc) 34%, transparent) 0deg 9deg,
    transparent 9deg 22.5deg
  );
  -webkit-mask-image: radial-gradient(circle, #000 12%, transparent 62%);
  mask-image: radial-gradient(circle, #000 12%, transparent 62%);
  animation: win-spin 48s linear infinite;
}
.win-medal {
  position: relative;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #fff 0%, color-mix(in srgb, var(--cc) 22%, #fff) 100%);
  box-shadow:
    0 0 0 7px var(--cc),
    0 0 0 11px #fff,
    0 10px 0 11px color-mix(in srgb, var(--cc) 62%, #000),
    0 18px 28px rgba(30, 20, 90, 0.3);
  display: grid;
  place-items: center;
  animation: win-pop 0.7s cubic-bezier(0.2, 1.5, 0.35, 1) 0.2s both;
}
.win-medal canvas {
  width: 150px;
  height: 118px;
  margin-top: 6px;
  animation: win-bob 1.6s ease-in-out 1s infinite;
}
.win-crown {
  position: absolute;
  top: -34px;
  left: 50%;
  width: 74px;
  height: 56px;
  margin-left: -37px;
  transform-origin: 50% 100%;
  filter: drop-shadow(0 4px 0 rgba(120, 78, 0, 0.35));
  animation: win-crown-in 0.6s cubic-bezier(0.2, 1.6, 0.4, 1) 0.7s both;
}
.win-spark {
  position: absolute;
  color: #ffc928;
  font-size: 26px;
  line-height: 1;
  filter: drop-shadow(0 2px 0 rgba(150, 100, 0, 0.35));
  animation: win-twinkle 1.8s ease-in-out infinite;
}
.win-spark:nth-of-type(1) {
  left: 14%;
  top: 22%;
}
.win-spark:nth-of-type(2) {
  right: 13%;
  top: 14%;
  font-size: 34px;
  animation-delay: 0.5s;
}
.win-spark:nth-of-type(3) {
  right: 20%;
  bottom: 14%;
  font-size: 20px;
  animation-delay: 1.1s;
}

/* ---- title plaque: soft rounded capsule in the winner colour, no hard corners */
#win .win-title {
  position: relative;
  display: inline-block;
  max-width: calc(100% - 8px);
  box-sizing: border-box;
  margin: 6px 0 0;
  padding: 9px 34px 11px;
  border-radius: 30px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--cc) 82%, #fff) 0%, var(--cc) 55%);
  color: var(--tc);
  font-size: clamp(30px, 8.6vw, 42px);
  line-height: 1.05;
  text-shadow: 0 2px 0 color-mix(in srgb, var(--cc) 72%, var(--tc));
  box-shadow:
    0 6px 0 color-mix(in srgb, var(--cc) 62%, #000),
    0 14px 22px color-mix(in srgb, var(--cc) 40%, transparent),
    inset 0 2px 0 rgba(255, 255, 255, 0.45),
    inset 0 0 0 3px rgba(255, 255, 255, 0.18);
  animation: win-title-in 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) 0.45s both;
}
#win .win-title::before,
#win .win-title::after {
  content: '✦';
  position: absolute;
  top: 50%;
  margin-top: -0.5em;
  font-size: 0.5em;
  line-height: 1;
  opacity: 0.55;
}
#win .win-title::before {
  left: 14px;
}
#win .win-title::after {
  right: 14px;
}

/* ---- stat pieces shared by the champion line and runner-up rows */
.win-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin: 16px 0 8px;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  animation: win-fade 0.4s ease 0.8s both;
}
.pips {
  display: inline-flex;
  gap: 4px;
}
.pips i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--cc) 55%, #fff);
}
.pips i.on {
  background: var(--cc);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--cc) 62%, #000) inset;
}
.win-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px 3px;
  border-radius: 999px;
  background: #fff;
  box-shadow: inset 0 0 0 2px #e4e2f6;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---- runner-up rows */
#win .rank {
  list-style: none;
  margin: 12px 0 4px;
  padding: 0;
  gap: 8px;
}
#win .rank li {
  display: grid;
  grid-template-columns: 30px 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 10px;
  border-radius: 18px;
  background: #fff;
  color: var(--ink);
  box-shadow:
    inset 0 0 0 2px color-mix(in srgb, var(--cc) 38%, #fff),
    0 3px 0 color-mix(in srgb, var(--cc) 30%, #d9d7f0);
  font-size: 16px;
  text-align: left;
  animation: rank-in 0.45s cubic-bezier(0.2, 0.8, 0.25, 1.2) both;
  animation-delay: calc(var(--i) * 0.12s + 0.85s);
}
#win .rank .pos {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #ece9fa;
  font: 700 15px/1 var(--font-display);
  color: var(--soft);
}
#win .rank li:nth-child(1) .pos {
  background: #e5e8ee;
  color: #5d6678;
}
#win .rank li:nth-child(2) .pos {
  background: #f3d9bd;
  color: #85521f;
}
#win .rank .rank-cat {
  width: 56px;
  height: 44px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--cc) 20%, #fff);
  animation: none;
}
#win .rank .nm {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 700;
  overflow-wrap: anywhere;
}
#win .rank .nm .pips {
  justify-self: start;
}
#win .rank .chips {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  font-size: 13px;
  font-weight: 700;
}
#win .rank .win-chip {
  padding: 0 8px 1px;
  background: #f3f1fc;
  box-shadow: none;
}

/* ---- prize + fun facts */
#win .win-notes {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 16px 0;
  font-size: 14px;
  color: var(--ink);
}
#win .win-notes:empty {
  display: none;
}
.win-note {
  padding: 4px 11px 5px;
  border-radius: 999px;
  background: #f0eefb;
  font-weight: 700;
  animation: win-fade 0.4s ease 1.3s both;
}
.win-note.prize {
  flex-basis: 100%;
  padding: 9px 14px 10px;
  border-radius: 16px;
  background: linear-gradient(180deg, #fffaf0, #fff0bd);
  color: #6a4a00;
  font-size: 15px;
  box-shadow:
    inset 0 0 0 2px #f2c94c,
    0 3px 0 #e6b73a;
  animation: win-fade 0.4s ease 1.2s both, win-glow 1.6s ease-in-out 1.8s infinite;
}
#win .play {
  margin-top: 4px;
}
#win .ghost {
  min-height: 48px;
  margin-top: 8px;
  border: 2px solid #d4cff1;
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}
.pcount {
  margin-left: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--soft);
  font-variant-numeric: tabular-nums;
}
#win .rank .nm .row {
  display: flex;
  align-items: center;
}

/* confetti over the hero, one burst when the card opens */
.win-confetti {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 100%;
  pointer-events: none;
}
.win-confetti i {
  position: absolute;
  top: -14px;
  width: 9px;
  height: 14px;
  border-radius: 3px;
  background: var(--k);
  opacity: 0;
  animation: win-fall var(--d) ease-in var(--w) 1 both;
}
@keyframes win-fall {
  0% {
    opacity: 1;
    transform: translateY(0) rotate(0);
  }
  100% {
    opacity: 0;
    transform: translateY(420px) rotate(var(--r));
  }
}

@keyframes win-spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes win-pop {
  from {
    opacity: 0;
    transform: scale(0.4) rotate(-12deg);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes win-bob {
  0%,
  100% {
    transform: translateY(0) rotate(0);
  }
  40% {
    transform: translateY(-5px) rotate(-2deg);
  }
  70% {
    transform: translateY(0) rotate(2deg);
  }
}
@keyframes win-crown-in {
  from {
    opacity: 0;
    transform: translateY(-40px) rotate(-24deg) scale(0.6);
  }
  to {
    opacity: 1;
    transform: rotate(-6deg);
  }
}
@keyframes win-twinkle {
  0%,
  100% {
    opacity: 0.35;
    transform: scale(0.7) rotate(0);
  }
  50% {
    opacity: 1;
    transform: scale(1.1) rotate(20deg);
  }
}
@keyframes win-title-in {
  from {
    opacity: 0;
    transform: scale(0.6);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes win-fade {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes win-glow {
  0%,
  100% {
    box-shadow:
      inset 0 0 0 2px #f2c94c,
      0 3px 0 #e6b73a,
      0 0 0 0 rgba(255, 201, 40, 0.55);
  }
  50% {
    box-shadow:
      inset 0 0 0 2px #f2c94c,
      0 3px 0 #e6b73a,
      0 0 0 8px rgba(255, 201, 40, 0);
  }
}

@media (max-height: 760px) {
  .win-hero {
    height: 172px;
    padding-top: 22px;
  }
  .win-medal {
    width: 120px;
    height: 120px;
  }
  .win-medal canvas {
    width: 120px;
    height: 94px;
  }
  .win-crown {
    top: -28px;
    width: 60px;
    height: 46px;
    margin-left: -30px;
  }
}
@media (max-height: 680px) {
  #win .win-note:not(.prize) {
    display: none;
  }
  .win-hero {
    height: 146px;
    padding-top: 20px;
  }
  .win-medal {
    width: 98px;
    height: 98px;
  }
  .win-medal canvas {
    width: 98px;
    height: 77px;
    margin-top: 4px;
  }
  .win-crown {
    top: -24px;
    width: 52px;
    height: 40px;
    margin-left: -26px;
  }
  #win .win-title {
    font-size: clamp(26px, 7.6vw, 34px);
  }
}
@media (max-width: 400px) {
  #win .rank li {
    grid-template-columns: 26px 46px minmax(0, 1fr) auto;
    gap: 8px;
    font-size: 15px;
  }
  #win .rank .rank-cat {
    width: 46px;
    height: 36px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .win-rays,
  .win-medal,
  .win-medal canvas,
  .win-crown,
  .win-spark,
  #win .win-title,
  .win-stats,
  #win .rank li,
  .win-note,
  .win-note.prize {
    animation: none;
  }
  .win-confetti {
    display: none;
  }
  .win-spark {
    opacity: 0.8;
  }
}

/* End of css/win.css */
