@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;600;700&display=swap");

:root {
  --bg: #f5f1ea;
  --panel: #fefbf6;
  --ink: #2a2a2a;
  --accent: #e2725b;
  --accent-dark: #b6523f;
  --tower: #4b3f36;
  --tower-light: #6a5a4d;
  --tower-height: 320px;
  --disk-height: 22px;
  --disk-gap: 8px;
  --disk-1: #f2b134;
  --disk-2: #f26b38;
  --disk-3: #eb5160;
  --disk-4: #bb4a59;
  --disk-5: #785589;
  --disk-6: #4f6d7a;
  --disk-7: #2d6a4f;
  --disk-8: #6a994e;
  --disk-9: #f0a202;
  --disk-10: #dd7230;
  --disk-11: #b83b5e;
  --disk-12: #5c4d7d;
  --disk-13: #2f4858;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", system-ui, sans-serif;
  background: radial-gradient(circle at top, #fff8ec 0%, #f1e9de 45%, #e8dfd1 100%);
  color: var(--ink);
  min-height: 100vh;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 20px 50px;
}

.app__header {
  display: flex;
  flex-wrap: wrap;
  gap: 30px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 30px;
}

.app__kicker {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.7rem;
  margin: 0 0 6px;
  color: #6b5b53;
}

.app__title {
  font-size: clamp(2rem, 4vw, 3.3rem);
  margin: 0 0 10px;
}

.app__subtitle {
  margin: 0;
  max-width: 540px;
  color: #544b44;
}

.controls {
  background: var(--panel);
  padding: 18px;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(50, 40, 30, 0.1);
  min-width: 260px;
  display: grid;
  gap: 16px;
}

.auth {
  display: grid;
  gap: 8px;
}

.auth__label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #6b5b53;
}

.auth__user {
  margin: 0;
  font-size: 0.9rem;
  color: #4a403a;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-weight: 600;
}

.control input[type="range"] {
  accent-color: var(--accent);
}

.control-buttons {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.btn {
  background: var(--accent);
  border: none;
  color: white;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.btn:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.btn--ghost {
  background: transparent;
  border: 2px solid var(--accent);
  color: var(--accent);
}

.btn--ghost:hover {
  background: var(--accent);
  color: #fff;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 30px;
}

.stat {
  background: var(--panel);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 8px 20px rgba(50, 40, 30, 0.08);
}

.stat__label {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #6b5b53;
}

.stat__value {
  font-size: 1.6rem;
  font-weight: 700;
}

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  align-items: end;
  margin-bottom: 20px;
}

.tower {
  height: var(--tower-height);
  border-radius: 18px;
  border: none;
  background: linear-gradient(180deg, #fef8f0 0%, #f1e6d7 100%);
  position: relative;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  padding: 20px 12px;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(80, 60, 40, 0.2);
}

.tower::before {
  content: "";
  position: absolute;
  bottom: 20px;
  width: 18px;
  height: calc(var(--tower-height) - 90px);
  background: linear-gradient(180deg, var(--tower-light) 0%, var(--tower) 100%);
  border-radius: 10px;
}

.tower--active {
  outline: 3px solid rgba(226, 114, 91, 0.6);
}

.disk {
  height: var(--disk-height);
  border-radius: 999px;
  margin-bottom: var(--disk-gap);
  box-shadow: 0 6px 10px rgba(0, 0, 0, 0.15);
  border: 2px solid rgba(255, 255, 255, 0.6);
  position: relative;
  z-index: 1;
}

.message {
  background: var(--panel);
  padding: 14px 16px;
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(50, 40, 30, 0.08);
  font-size: 0.95rem;
}

.leaderboard {
  margin-top: 24px;
  background: var(--panel);
  padding: 16px;
  border-radius: 16px;
  box-shadow: 0 8px 20px rgba(50, 40, 30, 0.08);
}

.leaderboard__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.leaderboard__header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.leaderboard__filters {
  display: flex;
  gap: 10px;
  align-items: center;
}

.leaderboard__filter {
  display: grid;
  gap: 4px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b5b53;
}

.leaderboard__filter input {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #d6c9bb;
  background: #fffdfa;
  text-transform: uppercase;
}

.leaderboard__list {
  margin: 12px 0 0;
  padding-left: 20px;
  display: grid;
  gap: 10px;
}

.leaderboard__item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: #fffdfa;
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: inset 0 0 0 1px rgba(80, 60, 40, 0.08);
}

.leaderboard__meta {
  display: grid;
  gap: 2px;
}

.leaderboard__name {
  font-weight: 600;
}

.leaderboard__detail {
  font-size: 0.85rem;
  color: #6b5b53;
}

.debug {
  margin-top: 20px;
  background: #1b1b1b;
  color: #f1f1f1;
  padding: 14px;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.debug__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.debug__header h3 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.debug__output {
  margin: 12px 0 0;
  background: #111;
  border-radius: 10px;
  padding: 12px;
  font-size: 0.85rem;
  line-height: 1.4;
  max-height: 200px;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.confetti {
  pointer-events: none;
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 50;
}

.confetti__piece {
  position: absolute;
  top: -10px;
  width: 10px;
  height: 16px;
  opacity: 0.9;
  animation: confetti-fall 1.6s ease-in forwards;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(0) rotate(0deg);
  }
  100% {
    transform: translateY(110vh) rotate(720deg);
    opacity: 0;
  }
}

@media (max-width: 720px) {
  .board {
    grid-template-columns: 1fr;
  }

  .tower {
    height: calc(var(--tower-height) - 60px);
  }
}
