*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Fredoka", "Baloo 2", "Trebuchet MS", sans-serif;
  background: radial-gradient(circle at top, #4A90E2 0%, #1A5490 100%);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem clamp(1rem, 4vw, 3rem) 3rem;
  overflow-x: hidden;
}

.ambient-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: conic-gradient(
    from 180deg at 50% 50%,
    rgba(220, 10, 45, 0.5),
    rgba(59, 76, 202, 0.4),
    rgba(255, 222, 0, 0.5),
    rgba(220, 10, 45, 0.5)
  );
  filter: blur(160px);
  opacity: 0.5;
  animation: glowPulse 12s infinite alternate;
}

@keyframes glowPulse {
  from {
    transform: scale(1);
    opacity: 0.5;
  }
  to {
    transform: scale(1.2);
    opacity: 0.75;
  }
}

.hero {
  text-align: center;
  margin-bottom: 1.5rem;
  z-index: 1;
}

.hero h1 {
  margin: 0.2rem 0;
  font-size: clamp(2.25rem, 6vw, 3.5rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #FFDE00;
  text-shadow: 0 0 12px rgba(255, 222, 0, 0.8), 0 0 24px rgba(255, 222, 0, 0.4);
}

.tagline {
  margin: 0 auto;
  max-width: 28rem;
  font-size: 1rem;
  color: #ffffff;
}

.toggles {
  margin-top: 1rem;
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  background: rgba(26, 42, 80, 0.8);
  border: 2px solid rgba(255, 255, 255, 0.4);
  font-weight: 600;
  cursor: pointer;
}

.toggle input {
  accent-color: #DC0A2D;
  width: 1rem;
  height: 1rem;
}

.arena {
  width: min(62rem, 100%);
  display: grid;
  gap: 1.5rem;
  z-index: 1;
}

.card {
  position: relative;
  padding: clamp(1.4rem, 3vw, 2.25rem);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.95);
  border: 3px solid #FFDE00;
  box-shadow: 0 20px 38px rgba(0, 0, 0, 0.3), 0 0 20px rgba(255, 222, 0, 0.3);
  backdrop-filter: blur(12px);
}

.card::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 22px;
  border: 2px dashed rgba(220, 10, 45, 0.2);
  pointer-events: none;
}

.stage.hidden {
  display: none;
}

.scoreboard.hidden {
  display: none;
}

.card h2 {
  margin-top: 0;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #DC0A2D;
}

.intro {
  margin-top: 0.2rem;
  color: #1A5490;
  font-size: 1rem;
}

.setup-form {
  display: grid;
  gap: 1.5rem;
}

.field {
  display: grid;
  gap: 0.35rem;
}

.field label {
  font-weight: 600;
  letter-spacing: 0.02em;
}

.input-with-note {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  flex-wrap: wrap;
}

input[type="number"],
input[type="text"] {
  padding: 0.6rem 0.8rem;
  border-radius: 14px;
  border: 2px solid #3B4CCA;
  background: rgba(255, 255, 255, 0.9);
  color: #000;
  font-size: 1rem;
  width: 5.5rem;
}

input[type="text"] {
  width: 100%;
}

.note {
  font-size: 0.85rem;
  color: #1A5490;
}

.trainer-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.trainer-card {
  padding: 1rem;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid #3B4CCA;
  display: grid;
  gap: 0.6rem;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.trainer-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 28px rgba(59, 76, 202, 0.5);
}

.emoji-options {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.emoji-options button {
  flex: 1 1 auto;
  min-width: 44px;
  padding: 0.4rem 0.6rem;
  border-radius: 12px;
  border: 2px solid transparent;
  background: rgba(59, 76, 202, 0.15);
  color: #000;
  font-size: 1.2rem;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.emoji-options button.active {
  border-color: #FFDE00;
  transform: scale(1.05);
  background: rgba(255, 222, 0, 0.3);
}

.action {
  font-size: 1.05rem;
  font-weight: 700;
  text-transform: uppercase;
  border-radius: 999px;
  border: none;
  padding: 0.9rem 1.6rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
  letter-spacing: 0.05em;
}

.action.primary {
  background: linear-gradient(135deg, #DC0A2D, #FF6B6B);
  color: #ffffff;
  box-shadow: 0 12px 22px rgba(220, 10, 45, 0.5);
}

.action.secondary {
  background: linear-gradient(135deg, #3B4CCA, #5865F2);
  color: #ffffff;
  box-shadow: 0 12px 22px rgba(59, 76, 202, 0.5);
}

.action:hover:not(:disabled),
.action:focus:not(:disabled) {
  outline: none;
  transform: translateY(-2px) scale(1.02);
  filter: brightness(1.05);
}

.action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1.5rem;
  justify-content: center;
}

.decree-stage {
  display: grid;
  gap: 1.2rem;
  justify-items: center;
}

.card-flip {
  display: none;
  gap: 1.1rem;
  justify-items: center;
  pointer-events: none;
}

.card-flip.active {
  display: grid;
  animation: fadeIn 0.35s ease forwards;
}

.flip-row {
  display: flex;
  gap: clamp(0.4rem, 2.4vw, 1rem);
  align-items: flex-end;
}

.flip-card {
  width: clamp(58px, 14vw, 84px);
  height: clamp(78px, 20vw, 116px);
  border-radius: 16px;
  border: 3px solid #DC0A2D;
  background: white;
  box-shadow: 0 16px 26px rgba(0, 0, 0, 0.35);
  display: grid;
  place-items: center;
  font-size: clamp(1.5rem, 5vw, 2.2rem);
  color: #000;
  opacity: 0;
  transform: translateY(-140px) scale(0.78) rotate(-8deg);
  animation: cardDrop 1s ease-out forwards;
  animation-delay: var(--card-delay, 0ms);
}

.flip-card span {
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.35));
}

.flip-center {
  width: clamp(64px, 16vw, 92px);
  height: clamp(64px, 16vw, 92px);
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, #FFDE00, #DC0A2D 70%);
  display: grid;
  place-items: center;
  font-size: clamp(1.8rem, 6vw, 2.4rem);
  font-weight: 800;
  color: #ffffff;
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.35), 0 0 16px rgba(255, 222, 0, 0.8);
  opacity: 0;
  transform: scale(0.4);
}

.card-flip.show-question .flip-center {
  animation: questionPop 0.8s ease-out forwards;
}

.judging-panel {
  margin-top: 1.6rem;
  padding: clamp(1.2rem, 3vw, 1.8rem);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.95);
  border: 2px dashed #3B4CCA;
  display: grid;
  gap: 1.2rem;
}

.judging-panel.hidden {
  display: none;
}

.judging-intro {
  text-align: center;
  color: #1A5490;
}

.judging-panel .trainer-grid {
  margin-top: 0.2rem;
}

.judging-panel .action {
  justify-self: center;
}

.decree {
  margin-top: 1rem;
  padding: 1.6rem;
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(220, 10, 45, 0.9), rgba(255, 222, 0, 0.9));
  border: 3px solid #FFDE00;
  font-size: clamp(1.2rem, 3.6vw, 1.7rem);
  font-weight: 700;
  text-align: center;
  color: #000;
  cursor: pointer;
  box-shadow: 0 15px 36px rgba(220, 10, 45, 0.5);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.25s ease;
}

.decree.is-concealed {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.decree-emoji {
  font-size: clamp(2.2rem, 6vw, 3rem);
  margin-bottom: 0.8rem;
}

.decree-text {
  display: grid;
  gap: 0.3rem;
  font-size: 1.05em;
}

.decree-text strong {
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #000;
  text-shadow: 0 0 4px rgba(255, 222, 0, 0.8);
}

.decree-text span {
  display: block;
  color: #000;
  line-height: 1.4;
}

.decree:hover,
.decree:focus {
  transform: translateY(-3px) scale(1.01);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
  outline: none;
}

.scoreboard {
  display: grid;
  gap: 1rem;
  padding-bottom: 1.5rem;
}

.scoreboard header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.score-target {
  font-size: 0.95rem;
  color: #1A5490;
}

.score-list {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.score-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem 1rem;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 18px;
  border: 2px solid #3B4CCA;
  position: relative;
  overflow: hidden;
}

.score-item::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255, 222, 0, 0.4));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.score-item.leader::after {
  opacity: 1;
}

.trainer-badge {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: #000;
  background: #FFDE00;
  border: 2px solid #DC0A2D;
  box-shadow: 0 0 12px rgba(255, 222, 0, 0.7);
}

.trainer-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.trainer-name {
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #000;
}

.score-count {
  font-size: 0.95rem;
  color: #1A5490;
  font-weight: 600;
}

.star-track {
  display: flex;
  gap: 0.35rem;
}

.star-track span {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #3B4CCA;
  background: rgba(255, 255, 255, 0.5);
}

.star-track span.filled {
  background: linear-gradient(135deg, #FFDE00, #FFC700);
  border-color: #DC0A2D;
  box-shadow: 0 0 10px rgba(255, 222, 0, 0.8);
}

.star-button {
  border: 3px solid #3B4CCA;
  border-radius: 18px;
  padding: 1.1rem;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  gap: 0.4rem;
  justify-items: center;
  background: white;
  color: #000;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.star-button span {
  display: block;
}

.star-button-emoji {
  font-size: 1.8rem;
}

.star-button-name {
  font-size: 1.05rem;
}

.star-button-cta {
  font-size: 0.95rem;
  letter-spacing: 0.05em;
}

.star-button:hover,
.star-button:focus {
  transform: translateY(-3px);
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.4);
  outline: none;
}

.star-button.selected {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 18px 32px rgba(255, 222, 0, 0.6);
  border: 3px solid #FFDE00;
  background: rgba(255, 222, 0, 0.2);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes cardDrop {
  0% {
    opacity: 0;
    transform: translateY(-140px) scale(0.78) rotate(-8deg);
  }
  70% {
    opacity: 1;
    transform: translateY(10px) scale(1.02) rotate(3deg);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0deg);
  }
}

@keyframes questionPop {
  0% {
    opacity: 0;
    transform: scale(0.4);
  }
  70% {
    opacity: 1;
    transform: scale(1.1);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.champion-display {
  display: grid;
  gap: 1rem;
  justify-items: center;
  margin: 1.5rem 0;
}

.champion-name {
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  font-weight: 800;
  color: #FFDE00;
  text-shadow: 0 0 18px rgba(255, 222, 0, 0.9), 2px 2px 4px rgba(220, 10, 45, 0.5);
}

.champion-name.multiple {
  text-align: center;
}

.confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 18px;
  opacity: 0.9;
  border-radius: 4px;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  to {
    transform: translateY(120vh) rotate(360deg);
    opacity: 0;
  }
}

.footer {
  margin-top: 2rem;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.85);
  text-align: center;
  z-index: 1;
}

@media (max-width: 600px) {
  body {
    padding: 1.2rem;
  }

  .hero h1 {
    font-size: 2.2rem;
  }

  .action {
    width: 100%;
  }

  .button-row {
    gap: 0.8rem;
  }
}
