:root {
  --bg: #f5fff5;
  --ink: #0d1b12;
  --muted: #5f7165;
  --green: #26b957;
  --green-deep: #12813a;
  --green-soft: #dcf8e5;
  --card: rgba(255, 255, 255, 0.88);
  --stroke: rgba(18, 129, 58, 0.18);
  --shadow: 0 24px 70px rgba(11, 69, 31, 0.14);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at 18% 12%, rgba(38, 185, 87, 0.18), transparent 28rem),
    radial-gradient(circle at 88% 20%, rgba(255, 255, 255, 0.92), transparent 24rem),
    linear-gradient(135deg, #f7fff8 0%, #e9f8ee 52%, #ffffff 100%);
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  overflow: hidden;
  scrollbar-gutter: stable;
}

body.is-ball-drop {
  overflow: hidden;
}

.page {
  width: min(1180px, calc(100% - 24px));
  min-height: 100dvh;
  margin: 0 auto;
  padding: 14px 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  gap: 10px;
}

.topbar,
.top-nav,
.brand,
.hero,
.hero-actions,
.section-head {
  display: flex;
}

.topbar {
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-family: "Archivo Black", Impact, sans-serif;
  font-size: clamp(1.6rem, 3.5vw, 2.8rem);
  line-height: 1;
  letter-spacing: -0.03em;
  text-decoration: none;
}

.brand img {
  width: clamp(46px, 7vw, 72px);
  height: clamp(46px, 7vw, 72px);
  border-radius: 50%;
  box-shadow: 0 10px 24px rgba(11, 69, 31, 0.18);
}

.top-nav {
  gap: 10px;
  flex-wrap: wrap;
}

.top-nav a,
.ca-pill,
.info-btn,
.test-btn {
  border: 1px solid var(--stroke);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink);
  text-decoration: none;
  backdrop-filter: blur(10px);
}

.top-nav a {
  padding: 8px 12px;
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero {
  align-items: center;
  justify-content: space-between;
  gap: clamp(18px, 5vw, 64px);
  min-height: 0;
}

.hero-copy {
  flex: 1 1 520px;
}

.eyebrow {
  display: inline-flex;
  margin: 0 0 9px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-deep);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: 720px;
  font-family: "Archivo Black", Impact, sans-serif;
  font-size: clamp(3rem, 7vw, 6.4rem);
  line-height: 0.92;
  letter-spacing: -0.07em;
}

.subhead {
  max-width: 650px;
  margin: 14px 0;
  color: var(--muted);
  font-size: clamp(0.98rem, 1.8vw, 1.14rem);
  font-weight: 700;
}

.hero-actions {
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ca-pill,
.info-btn,
.test-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  max-width: 100%;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 900;
}

.ca-pill {
  font: 800 0.78rem ui-monospace, "Cascadia Code", Consolas, monospace;
}

.info-btn {
  background: var(--green);
  color: white;
  border-color: transparent;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.test-btn {
  background: #fff;
  color: var(--green-deep);
  border-color: rgba(18, 129, 58, 0.28);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ca-label {
  color: var(--green-deep);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
}

.ca-pill-addr {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-toast {
  display: block;
  min-height: 1.2rem;
  margin-top: 6px;
  color: var(--green-deep);
  font-weight: 800;
}

.machine {
  position: relative;
  flex: 0 1 390px;
  min-height: min(360px, 48vh);
  display: grid;
  place-items: center;
}

.logo-orb {
  position: relative;
  z-index: 2;
  width: min(360px, 48vh, 86vw);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.logo-orb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.draw-balls {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.draw-balls span {
  position: absolute;
  width: 44px;
  height: 44px;
  border: 3px solid #101810;
  border-radius: 999px;
  background: white;
  box-shadow: 0 12px 24px rgba(11, 69, 31, 0.16);
}

.draw-balls span:nth-child(1) { top: 10%; left: 12%; }
.draw-balls span:nth-child(2) { top: 8%; right: 13%; }
.draw-balls span:nth-child(3) { right: -2%; top: 48%; }
.draw-balls span:nth-child(4) { bottom: 8%; right: 22%; }
.draw-balls span:nth-child(5) { bottom: 12%; left: 10%; }

.is-drawing .draw-balls {
  opacity: 1;
}

.is-drawing .draw-balls span {
  animation: ball-spin 0.65s linear infinite;
}

.is-drawing .logo-orb {
  animation: logo-pulse 0.48s ease-in-out infinite;
}

.cycle-card {
  position: absolute;
  z-index: 3;
  right: 0;
  bottom: 10px;
  min-width: 164px;
  padding: 12px 14px;
  border: 1px solid var(--stroke);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.cycle-label,
.cycle-value {
  display: block;
}

.cycle-label {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cycle-value {
  color: var(--green-deep);
  font-family: "Archivo Black", Impact, sans-serif;
  font-size: 1.72rem;
  line-height: 1;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.stat-card,
.fame-card,
.modal {
  border: 1px solid var(--stroke);
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.stat-card {
  min-height: 118px;
  padding: 14px 16px;
}

.stat-card--pot {
  background: linear-gradient(145deg, rgba(220, 248, 229, 0.95), rgba(255, 255, 255, 0.9));
}

.stat-card h2,
.section-head h2 {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.stat-big {
  margin: 6px 0 2px;
  color: var(--green-deep);
  font-family: "Archivo Black", Impact, sans-serif;
  font-size: clamp(1.65rem, 3.2vw, 2.55rem);
  line-height: 1;
}

.stat-small,
.section-head p,
footer,
.modal p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.82rem;
}

.winner-list {
  margin: 8px 0 0;
  padding-left: 1.35rem;
  font-size: 0.84rem;
  font-weight: 800;
}

.winner-list li + li {
  margin-top: 4px;
}

.winner-list a,
.fame-table a {
  color: var(--green-deep);
  text-decoration: none;
}

.muted {
  color: var(--muted);
  font-weight: 700;
}

.fame-card {
  overflow: hidden;
}

.section-head {
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px 6px;
}

.table-wrap {
  overflow-x: auto;
  max-height: 166px;
  overflow-y: auto;
}

.fame-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 540px;
}

.fame-table th,
.fame-table td {
  padding: 8px 16px;
  border-top: 1px solid rgba(18, 129, 58, 0.12);
  text-align: left;
}

.fame-table th {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.fame-table td {
  font-size: 0.84rem;
  font-weight: 800;
}

.empty td {
  color: var(--muted);
  text-align: center;
}

footer {
  max-width: 840px;
  margin: 0 auto;
  font-size: 0.72rem;
  text-align: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(7, 20, 11, 0.45);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  position: relative;
  width: min(560px, 100%);
  padding: 24px;
}

.modal h2 {
  margin: 0 0 10px;
  font-family: "Archivo Black", Impact, sans-serif;
  font-size: 2rem;
  letter-spacing: -0.04em;
}

.modal p + p {
  margin-top: 10px;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: var(--green);
  color: white;
  cursor: pointer;
  font-weight: 900;
}

.formula {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0;
  font-weight: 900;
}

.formula span {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-deep);
}

.formula strong {
  color: var(--green-deep);
}

.falling-balls {
  position: fixed;
  inset: 0;
  z-index: 12;
  pointer-events: none;
  overflow: hidden;
}

.falling-balls span {
  position: absolute;
  top: -90px;
  width: var(--ball-size, 48px);
  height: var(--ball-size, 48px);
  display: grid;
  place-items: center;
  border: 3px solid #101810;
  border-radius: 999px;
  background:
    radial-gradient(circle at 34% 28%, #fff 0 18%, transparent 20%),
    var(--green);
  color: #101810;
  font-family: "Archivo Black", Impact, sans-serif;
  font-size: calc(var(--ball-size, 48px) * 0.34);
  line-height: 1;
  box-shadow: 0 14px 22px rgba(11, 69, 31, 0.18);
  opacity: 0;
}

.falling-balls span:nth-child(1) { left: 4%; --ball-size: 42px; --drift: 42px; --spin: 410deg; }
.falling-balls span:nth-child(2) { left: 13%; --ball-size: 56px; --drift: -28px; --spin: -620deg; }
.falling-balls span:nth-child(3) { left: 24%; --ball-size: 46px; --drift: 76px; --spin: 540deg; }
.falling-balls span:nth-child(4) { left: 35%; --ball-size: 62px; --drift: -54px; --spin: -380deg; }
.falling-balls span:nth-child(5) { left: 47%; --ball-size: 39px; --drift: 34px; --spin: 720deg; }
.falling-balls span:nth-child(6) { left: 57%; --ball-size: 52px; --drift: -84px; --spin: -500deg; }
.falling-balls span:nth-child(7) { left: 68%; --ball-size: 44px; --drift: 62px; --spin: 660deg; }
.falling-balls span:nth-child(8) { left: 78%; --ball-size: 58px; --drift: -36px; --spin: -760deg; }
.falling-balls span:nth-child(9) { left: 88%; --ball-size: 48px; --drift: 24px; --spin: 480deg; }
.falling-balls span:nth-child(10) { left: 96%; --ball-size: 53px; --drift: -72px; --spin: -540deg; }

.is-ball-drop .falling-balls span {
  animation: ball-drop var(--fall-time, 2.8s) cubic-bezier(0.22, 0.74, 0.36, 1) infinite;
}

.is-ball-drop .falling-balls span:nth-child(2n) {
  background:
    radial-gradient(circle at 34% 28%, #fff 0 18%, transparent 20%),
    #ffffff;
}

.is-ball-drop .falling-balls span:nth-child(1) { animation-delay: 0.03s; --fall-time: 3.1s; }
.is-ball-drop .falling-balls span:nth-child(2) { animation-delay: 0.31s; --fall-time: 2.55s; }
.is-ball-drop .falling-balls span:nth-child(3) { animation-delay: 0.12s; --fall-time: 3.45s; }
.is-ball-drop .falling-balls span:nth-child(4) { animation-delay: 0.67s; --fall-time: 2.85s; }
.is-ball-drop .falling-balls span:nth-child(5) { animation-delay: 0.49s; --fall-time: 3.25s; }
.is-ball-drop .falling-balls span:nth-child(6) { animation-delay: 0.86s; --fall-time: 2.65s; }
.is-ball-drop .falling-balls span:nth-child(7) { animation-delay: 0.24s; --fall-time: 3.55s; }
.is-ball-drop .falling-balls span:nth-child(8) { animation-delay: 1.08s; --fall-time: 2.75s; }
.is-ball-drop .falling-balls span:nth-child(9) { animation-delay: 0.76s; --fall-time: 3.35s; }
.is-ball-drop .falling-balls span:nth-child(10) { animation-delay: 1.31s; --fall-time: 2.95s; }

@keyframes logo-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.025); }
}

@keyframes ball-spin {
  0% { transform: scale(0.82) rotate(0deg); }
  50% { transform: scale(1.12) rotate(180deg); }
  100% { transform: scale(0.82) rotate(360deg); }
}

@keyframes ball-drop {
  0% {
    opacity: 0;
    transform: translate3d(0, -90px, 0) rotate(0deg);
  }
  12% {
    opacity: 1;
  }
  38% {
    transform: translate3d(calc(var(--drift, 0px) * 0.45), 35vh, 0) rotate(calc(var(--spin, 540deg) * 0.38));
  }
  68% {
    transform: translate3d(calc(var(--drift, 0px) * -0.35), 68vh, 0) rotate(calc(var(--spin, 540deg) * 0.68));
  }
  82% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--drift, 0px), calc(100vh + 140px), 0) rotate(var(--spin, 540deg));
  }
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .page {
    min-height: auto;
  }

  .hero {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .machine {
    min-height: 300px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .cycle-card {
    left: 12px;
    right: 12px;
    bottom: 0;
  }
}
