:root {
  --ivory: #fbf6ea;
  --paper: #fffdf7;
  --burgundy: #6d1f36;
  --burgundy-dark: #4f1426;
  --burgundy-light: #8a3350;
  --blue-soft: #bcd4e6;
  --blue-deep: #2f5d84;
  --blue-deeper: #3f729b;
  --yellow: #f6e3a1;
  --yellow-strong: #f2d46b;
  --ink: #2b1a20;
  --danger: #8f1d2c;

  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--ivory);
  background-image: radial-gradient(rgba(109, 31, 54, 0.1) 1.5px, transparent 1.5px);
  background-size: 26px 26px;
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
  overflow-x: hidden;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

:focus-visible {
  outline: 4px solid var(--blue-deep);
  outline-offset: 3px;
}

/* Floating background shapes */
.backdrop {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.blob {
  position: absolute;
  display: block;
  border-radius: 50%;
  animation: float 14s ease-in-out infinite;
}

.blob--yellow {
  width: 34vmax;
  height: 34vmax;
  top: -12vmax;
  left: -10vmax;
  background: var(--yellow);
}

.blob--blue {
  width: 30vmax;
  height: 30vmax;
  right: -9vmax;
  top: 22vh;
  background: var(--blue-soft);
  animation-delay: -5s;
}

.blob--burgundy {
  width: 16vmax;
  height: 16vmax;
  left: 6vw;
  bottom: -6vmax;
  background: var(--burgundy);
  opacity: 0.9;
  animation-delay: -9s;
}

.blob--ring {
  width: 9vmax;
  height: 9vmax;
  right: 14vw;
  bottom: 10vh;
  border: 1.2vmax solid var(--yellow-strong);
  animation-delay: -2s;
}

@keyframes float {
  50% {
    transform: translate(2vmax, 3vmax) rotate(8deg);
  }
}

.page {
  position: relative;
  z-index: 1;
  width: min(100% - 2rem, 64rem);
  margin: 0 auto;
  padding: clamp(1.5rem, 5vw, 3.5rem) 0 3rem;
  display: grid;
  gap: clamp(1.25rem, 3vw, 2rem);
  justify-items: center;
}

/* Title */
.hero {
  text-align: center;
}

.hero__title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(3rem, 12vw, 6.5rem);
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--burgundy);
  transform: rotate(-2deg);
}

.hero__marker {
  display: inline-block;
  padding: 0 0.15em;
  background: linear-gradient(transparent 55%, var(--yellow-strong) 55%, var(--yellow-strong) 92%, transparent 92%);
}

.hero__subtitle {
  display: inline-block;
  margin: 1rem 0 0;
  padding: 0.35rem 1.25rem;
  border-radius: 999px;
  background: var(--burgundy);
  color: var(--yellow);
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.1rem, 3.5vw, 1.5rem);
  transform: rotate(1.5deg);
}

.notice {
  margin: 0;
  max-width: 40rem;
  padding: 0.8rem 1.2rem;
  border: 3px solid var(--blue-deep);
  border-radius: 18px;
  background: var(--blue-soft);
  color: #12283b;
  font-size: 0.95rem;
}

/* Score cards */
.stage {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1rem, 4vw, 3rem);
  align-items: start;
  padding-block: 0.5rem 1rem;
}

.player {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  gap: 1rem;
  padding: clamp(1.5rem, 4vw, 2rem) clamp(0.9rem, 3vw, 2rem) clamp(1.1rem, 3vw, 1.75rem);
  border: 4px solid var(--burgundy);
  border-radius: 36px;
  box-shadow: 8px 8px 0 var(--burgundy);
}

.player--sarah {
  background: var(--yellow);
  transform: rotate(-1.5deg);
  --fill: var(--burgundy);
  --fill-stripe: var(--burgundy-light);
}

.player--jake {
  background: var(--blue-soft);
  transform: rotate(1.5deg) translateY(1.5rem);
  --fill: var(--blue-deep);
  --fill-stripe: var(--blue-deeper);
}

.player__name {
  margin: -2.6rem 0 0;
  padding: 0.3rem 1.5rem;
  border-radius: 999px;
  background: var(--burgundy);
  color: var(--paper);
  font-family: var(--serif);
  font-size: clamp(1.25rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.player__score {
  margin: 0;
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(4rem, 17vw, 9rem);
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: lining-nums tabular-nums;
}

.player__score [data-score] {
  display: inline-block;
}

.pop {
  animation: pop 0.55s var(--bounce);
}

@keyframes pop {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(1.35) rotate(-4deg);
  }
  100% {
    transform: scale(1);
  }
}

/* Vertical bars */
.tower {
  width: clamp(4rem, 40%, 7rem);
  height: clamp(9rem, 28vw, 15rem);
  display: flex;
  align-items: flex-end;
  border: 4px solid var(--burgundy);
  border-radius: 999px;
  background: var(--paper);
  overflow: hidden;
}

.tower__fill {
  width: 100%;
  height: 0;
  background-color: var(--fill);
  background-image: repeating-linear-gradient(-45deg, var(--fill-stripe) 0 10px, transparent 10px 20px);
  border-radius: 999px;
  transition: height 0.9s var(--bounce);
}

/* Controls */
.controls {
  display: flex;
  gap: 0.9rem;
}

.step,
.custom__go,
.share {
  font: inherit;
  font-weight: 700;
  color: var(--burgundy);
  background: var(--paper);
  border: 3px solid var(--burgundy);
  cursor: pointer;
  box-shadow: 0 4px 0 var(--burgundy);
  transition: transform 0.1s, box-shadow 0.1s, background 0.15s;
}

.step:active,
.custom__go:active,
.share:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 var(--burgundy);
}

.step {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  font-size: 1.2rem;
}

.step--add {
  background: var(--burgundy);
  color: var(--paper);
}

.step:hover,
.custom__go:hover,
.share:hover {
  background: var(--ivory);
}

.step--add:hover {
  background: var(--burgundy-dark);
}

.custom {
  width: 100%;
  display: flex;
  gap: 0.5rem;
}

.custom input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0.4rem 0.9rem;
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 3px solid var(--burgundy);
  border-radius: 999px;
}

.custom__go {
  min-height: 44px;
  padding: 0 1.1rem;
  border-radius: 999px;
}

/* Lead line */
.lead {
  margin: 0.5rem 0 0;
  padding: 0.6rem 1.75rem;
  border: 4px solid var(--burgundy);
  border-radius: 999px;
  background: var(--burgundy);
  color: var(--yellow);
  box-shadow: 6px 6px 0 var(--yellow-strong);
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(1.3rem, 4.5vw, 2.2rem);
  text-align: center;
  transform: rotate(-1deg);
}

.error {
  margin: 0;
  color: var(--danger);
  font-weight: 700;
  text-align: center;
}

.error:empty {
  display: none;
}

.footer-actions {
  display: flex;
  justify-content: center;
}

.share {
  min-height: 48px;
  padding: 0 1.75rem;
  border-radius: 999px;
}

@media (max-width: 560px) {
  .player {
    gap: 0.8rem;
    border-radius: 28px;
    box-shadow: 5px 5px 0 var(--burgundy);
  }

  .player__name {
    margin-top: -2.3rem;
    padding-inline: 1.1rem;
  }

  .custom {
    flex-direction: column;
  }

  .custom__go {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
