:root {
  --bg-sky: #d8f0ff;
  --bg-cloud: #f9fffc;
  --board-blue: #1456d8;
  --board-blue-dark: #0d3ea8;
  --chip-red: #ff4b4b;
  --chip-yellow: #ffd447;
  --text-deep: #17203b;
  --text-soft: #345;
  --card: #ffffffd4;
  --shadow: 0 18px 45px rgba(20, 43, 90, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text-deep);
  background:
    radial-gradient(circle at 12% 18%, #fff9d7 0 15%, transparent 16%),
    radial-gradient(circle at 82% 12%, #c9f4ff 0 20%, transparent 21%),
    linear-gradient(155deg, var(--bg-sky), var(--bg-cloud));
  animation: sceneFade 600ms ease-out;
}

.app-shell {
  width: min(980px, 92vw);
  margin: 0 auto;
  padding: 1.6rem 0 2.5rem;
}

.hero {
  text-align: center;
  animation: riseIn 500ms ease-out;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #3f5f7a;
  font-weight: 700;
  font-size: 0.78rem;
}

h1 {
  margin: 0.25rem 0;
  font-family: "Bungee", cursive;
  font-size: clamp(2.1rem, 6vw, 3.6rem);
  color: #154fd2;
  text-shadow: 0 4px 0 #f9fbff;
}

.subtitle {
  margin-top: 0;
  color: var(--text-soft);
  font-size: clamp(0.95rem, 2.6vw, 1.15rem);
}

.hud {
  margin: 1rem auto 1.4rem;
  padding: 0.9rem;
  border-radius: 18px;
  background: var(--card);
  backdrop-filter: blur(4px);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 0.75rem;
  align-items: center;
  animation: riseIn 620ms ease-out;
}

.turn-box,
.score-box {
  border-radius: 12px;
  padding: 0.55rem 0.7rem;
  background: #f8fbff;
  border: 1px solid #dce7fb;
  font-weight: 700;
}

button {
  font-family: inherit;
  border: none;
  border-radius: 999px;
  padding: 0.65rem 1rem;
  background: #1b62f3;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, filter 160ms ease;
}

button:hover {
  transform: translateY(-2px);
  filter: brightness(1.04);
}

button:active {
  transform: translateY(0);
}

button.ghost {
  background: #f7faff;
  color: #1947a6;
  border: 1px solid #c3d6ff;
}

.board-wrap {
  width: min(760px, 100%);
  margin: 0 auto;
  position: relative;
}

.column-hint {
  position: absolute;
  top: -14px;
  width: calc((100% - 12px) / 7);
  height: 14px;
  border-radius: 12px;
  background: linear-gradient(90deg, #ffb84a, #ff7c3a);
  opacity: 0;
  pointer-events: none;
  transition: left 140ms ease, opacity 140ms ease;
}

.board {
  border-radius: 20px;
  background: linear-gradient(180deg, var(--board-blue), var(--board-blue-dark));
  padding: 14px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
}

.cell {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: #f2f8ff;
  border: 1px solid #c7d9f8;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.cell::after {
  content: "";
  position: absolute;
  inset: 7%;
  border-radius: 50%;
  background: transparent;
  transition: background 120ms ease;
}

.cell.red::after {
  background: radial-gradient(circle at 35% 32%, #ffd0d0, var(--chip-red) 58%);
  animation: chipDrop 280ms ease-out;
}

.cell.yellow::after {
  background: radial-gradient(circle at 35% 32%, #fff4bd, var(--chip-yellow) 58%);
  animation: chipDrop 280ms ease-out;
}

.cell.win::after {
  box-shadow: 0 0 0 3px #fff, 0 0 18px #ffffffcc;
}

.status {
  margin: 1rem auto;
  text-align: center;
  font-weight: 700;
  font-size: 1.05rem;
  color: #173b96;
}

.setup-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(10, 28, 74, 0.62);
  backdrop-filter: blur(4px);
  z-index: 60;
}

.setup-overlay.hidden {
  display: none;
}

.setup-card {
  width: min(460px, 90vw);
  border-radius: 18px;
  padding: 1.2rem 1.1rem 1rem;
  background: linear-gradient(180deg, #f9feff, #edf7ff);
  box-shadow: 0 26px 50px rgba(8, 27, 72, 0.35);
  animation: popIn 260ms ease-out;
}

.setup-kicker {
  margin: 0;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 700;
  color: #3861bb;
}

.setup-card h2 {
  margin: 0.28rem 0;
  font-family: "Bungee", cursive;
  font-size: clamp(1.35rem, 5vw, 1.85rem);
  font-weight: 400;
  color: #1848b6;
}

.setup-subtitle {
  margin: 0.2rem 0 0.7rem;
  color: #355;
  font-weight: 600;
}

.setup-form {
  display: grid;
  gap: 0.45rem;
}

.setup-form label {
  font-weight: 700;
  color: #22335f;
}

.setup-form input {
  border: 1px solid #c7d8fc;
  border-radius: 10px;
  font: inherit;
  padding: 0.58rem 0.65rem;
}

.setup-form button {
  margin-top: 0.6rem;
}

.winner-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(10, 28, 74, 0.58);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
  z-index: 50;
}

.winner-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.winner-overlay-card {
  position: relative;
  width: min(520px, 90vw);
  padding: 1.2rem 1.1rem 1rem;
  border-radius: 18px;
  background: linear-gradient(180deg, #f9feff, #edf7ff);
  box-shadow: 0 26px 50px rgba(8, 27, 72, 0.35);
  text-align: center;
  overflow: hidden;
  animation: popIn 260ms ease-out;
}

.confetti-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.winner-kicker,
.winner-overlay-card h2,
.winner-subtitle,
.winner-symbols,
#overlayNextRoundBtn {
  position: relative;
  z-index: 1;
}

.winner-kicker {
  margin: 0;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 700;
  color: #3861bb;
}

.winner-overlay-card h2 {
  margin: 0.3rem 0;
  font-family: "Bungee", cursive;
  font-size: clamp(1.4rem, 5vw, 2rem);
  font-weight: 400;
  color: #1848b6;
}

.winner-subtitle {
  margin: 0.25rem 0 0.6rem;
  color: #355;
  font-weight: 600;
}

.winner-symbols {
  min-height: 60px;
  margin-bottom: 0.7rem;
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.winner-symbol {
  font-size: clamp(1.1rem, 4vw, 1.7rem);
  animation: floatBurst 900ms ease-out forwards;
  transform-origin: center;
}

.rules {
  margin-top: 1.2rem;
  background: #ffffffba;
  border-radius: 16px;
  padding: 1rem 1.1rem;
  box-shadow: 0 10px 24px rgba(36, 70, 131, 0.12);
  animation: riseIn 760ms ease-out;
}

.rules h2 {
  margin-top: 0;
  font-family: "Bungee", cursive;
  color: #1d57d6;
  font-size: 1.35rem;
  font-weight: 400;
}

.rules ul {
  margin: 0.5rem 0;
}

.rules li {
  margin-bottom: 0.42rem;
}

.sources {
  margin-bottom: 0;
  font-size: 0.9rem;
}

.sources a {
  color: #1e61f0;
}

@keyframes chipDrop {
  from {
    transform: translateY(-120%) scale(0.9);
    opacity: 0.2;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes riseIn {
  from {
    transform: translateY(12px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes sceneFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes popIn {
  from {
    transform: scale(0.92);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes floatBurst {
  0% {
    transform: translateY(14px) scale(0.65) rotate(-8deg);
    opacity: 0;
  }
  35% {
    opacity: 1;
  }
  100% {
    transform: translateY(-12px) scale(1) rotate(8deg);
    opacity: 1;
  }
}

@media (max-width: 830px) {
  .hud {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  #newRoundBtn,
  #resetScoreBtn {
    grid-column: span 2;
  }
}

@media (max-width: 520px) {
  .app-shell {
    width: 95vw;
    padding-top: 1.1rem;
  }

  .board {
    gap: 7px;
    padding: 10px;
    border-radius: 14px;
  }

  .turn-box,
  .score-box {
    font-size: 0.9rem;
  }

  .status {
    font-size: 0.97rem;
  }
}
