@import url("https://fonts.googleapis.com/css2?family=Baloo+2:wght@600;700;800&family=Nunito:wght@500;700;800&display=swap");

:root {
  --green: #58cc02;
  --green-dark: #2f9e00;
  --green-soft: #e9ffd9;
  --blue: #1cb0f6;
  --blue-dark: #1090cb;
  --ink: #1c2a39;
  --ink-soft: #5d6f7f;
  --bg: #f6fff1;
  --card: #ffffff;
  --border: #dbe8c4;
  --shadow: 0 14px 30px rgba(10, 44, 17, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: "Nunito", "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  line-height: 1.55;
  background:
    radial-gradient(circle at 0 0, #efffe2 0%, transparent 42%),
    radial-gradient(circle at 100% 12%, #dff8ff 0%, transparent 34%),
    var(--bg);
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

.blob {
  position: fixed;
  width: 320px;
  height: 320px;
  border-radius: 999px;
  filter: blur(65px);
  opacity: 0.35;
  pointer-events: none;
  z-index: -1;
  animation: blob-float 11s ease-in-out infinite;
}

.blob-a {
  top: -70px;
  left: -80px;
  background: #bff4ff;
}

.blob-b {
  right: -120px;
  top: 160px;
  background: #d3ffc2;
  animation-delay: 1.6s;
}

.blob-c {
  bottom: -120px;
  left: 35%;
  background: #ffe7b3;
  animation-delay: 3.1s;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  width: min(1120px, 94vw);
  margin: 1rem auto 0;
  padding: 0.65rem 1rem;
  border: 2px solid rgba(212, 229, 183, 0.85);
  border-radius: 999px;
  backdrop-filter: blur(14px);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 8px 20px rgba(47, 158, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.topbar.topbar-scrolled {
  transform: translateY(-2px);
  box-shadow: 0 14px 24px rgba(47, 158, 0, 0.14);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  font-family: "Baloo 2", "Nunito", sans-serif;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 1rem;
}

.brand-text {
  font-size: 1.15rem;
  color: var(--green-dark);
}

.menu {
  display: flex;
  gap: 1rem;
  font-weight: 800;
  color: var(--ink-soft);
}

.menu a {
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.menu a:hover {
  background: var(--green-soft);
  color: var(--green-dark);
}

main,
.legal-shell {
  width: min(1120px, 92vw);
  margin: 2rem auto 3rem;
  display: grid;
  gap: 1.6rem;
}

.game-shell {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1.2rem;
}

.game-intro,
.game-panel,
.legal-header,
.legal-section {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.game-intro {
  padding: clamp(1.2rem, 2.1vw, 2rem);
}

.pill {
  display: inline-flex;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  margin: 0 0 0.75rem;
  background: var(--green-soft);
  color: var(--green-dark);
  border: 1px solid #c8ebb2;
  font-size: 0.9rem;
  font-weight: 800;
}

h1,
h2,
h3 {
  margin: 0 0 0.65rem;
  font-family: "Baloo 2", "Nunito", sans-serif;
  line-height: 1.15;
  letter-spacing: 0.01em;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.1rem);
}

h2 {
  font-size: clamp(1.35rem, 2.8vw, 2rem);
}

h3 {
  font-size: clamp(1.1rem, 2.1vw, 1.35rem);
}

p {
  margin: 0 0 0.85rem;
}

.game-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.rank-guide {
  margin-top: 0.9rem;
  padding: 0.85rem;
  border-radius: 14px;
  border: 1px dashed #c5deb0;
  background: #f8ffef;
}

.rank-guide p {
  margin: 0 0 0.45rem;
  font-weight: 800;
  color: var(--green-dark);
}

.rank-guide ul {
  margin: 0;
  padding-left: 1.05rem;
  color: var(--ink-soft);
  font-weight: 700;
}

.rank-guide li {
  margin: 0.22rem 0;
}

.challenge-box {
  margin-top: 0.8rem;
  padding: 0.9rem;
  border-radius: 14px;
  border: 1px solid #bfdef4;
  background: linear-gradient(120deg, #f5fcff, #eef8ff);
}

.challenge-box h3 {
  margin-bottom: 0.35rem;
  color: #1a7eaf;
  font-size: 1.04rem;
}

.challenge-box p {
  color: #4d667a;
  font-weight: 700;
}

.challenge-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1rem;
  margin-top: 0.4rem;
}

.challenge-stats p {
  margin: 0;
  color: #3f5a70;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 15px;
  border: 0;
  min-height: 48px;
  padding: 0.75rem 1.15rem;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn-primary {
  background: linear-gradient(130deg, var(--green), #7de127);
  color: #fff;
  box-shadow: 0 9px 0 #44a403;
}

.btn-primary:hover {
  box-shadow: 0 12px 0 #44a403;
}

.btn-secondary {
  background: linear-gradient(130deg, var(--blue), #47c5ff);
  color: #fff;
  box-shadow: 0 9px 0 var(--blue-dark);
}

.btn-secondary:hover {
  box-shadow: 0 12px 0 var(--blue-dark);
}

.game-panel {
  padding: 1rem;
}

.game-hud {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.35rem 0.75rem;
  color: var(--ink-soft);
  font-weight: 800;
}

.game-hud p {
  margin: 0;
}

.game-hud strong {
  color: var(--ink);
}

#countdown {
  color: #b74600;
}

.game-note {
  margin: 0.9rem 0 0;
  color: var(--ink-soft);
  font-weight: 700;
}

.result-board {
  margin-top: 0.9rem;
  border-radius: 14px;
  border: 1px solid #dceac6;
  padding: 0.75rem 0.85rem;
  background: #fbfff5;
}

.result-board h3 {
  margin-bottom: 0.45rem;
  color: #248500;
  font-size: 1.02rem;
}

.result-board ol {
  margin: 0;
  padding-left: 1.1rem;
}

.result-board li {
  margin: 0.2rem 0;
  color: var(--ink-soft);
  font-weight: 700;
}

.lights-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
  padding: 0.4rem;
}

.light-cell {
  appearance: none;
  border: 0;
  border-radius: 16px;
  aspect-ratio: 1 / 1;
  cursor: pointer;
  transition:
    transform 0.14s ease,
    box-shadow 0.2s ease,
    background-color 0.2s ease;
  background: #eff5e9;
  box-shadow: inset 0 -6px 0 #d8e4ca;
}

.light-cell:hover {
  transform: translateY(-2px);
}

.light-cell.active {
  background: linear-gradient(140deg, #1cb0f6, #50ceff);
  box-shadow:
    inset 0 -6px 0 #1693cf,
    0 0 16px rgba(28, 176, 246, 0.45);
}

.light-cell.hint {
  animation: hint-pulse 0.8s ease;
}

.light-cell:disabled {
  opacity: 0.58;
  cursor: not-allowed;
  transform: none;
}

.celebration-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 60;
}

.win-banner {
  position: absolute;
  left: 50%;
  top: 12%;
  transform: translate(-50%, -35px) scale(0.92);
  min-width: min(560px, 90vw);
  text-align: center;
  border-radius: 18px;
  border: 2px solid #f1c561;
  background: linear-gradient(135deg, #fff9df, #ffe6ae);
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.18);
  padding: 0.9rem 1rem;
  opacity: 0;
  animation: banner-drop 0.8s cubic-bezier(0.17, 0.89, 0.32, 1.24) forwards;
}

.win-banner h3 {
  margin: 0;
  color: #6f4e00;
}

.win-banner p {
  margin: 0.2rem 0 0;
  color: #6a5320;
  font-weight: 800;
}

.balloon {
  position: absolute;
  bottom: -130px;
  width: 42px;
  height: 58px;
  border-radius: 52% 52% 50% 50%;
  background: hsl(var(--hue), 90%, 63%);
  box-shadow: inset -6px -7px 0 hsla(0, 0%, 100%, 0.28);
  animation: balloon-rise var(--duration) linear forwards;
  animation-delay: var(--delay);
}

.balloon::after {
  content: "";
  position: absolute;
  width: 2px;
  height: 52px;
  left: 50%;
  top: 55px;
  transform: translateX(-50%);
  background: rgba(76, 88, 99, 0.44);
}

.burst-box {
  position: absolute;
  left: 50%;
  top: 54%;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: hsl(var(--hue), 92%, 58%);
  box-shadow: 0 0 12px hsla(var(--hue), 96%, 56%, 0.55);
  animation: burst 0.95s cubic-bezier(0.18, 0.83, 0.24, 1) forwards;
  animation-delay: var(--delay);
}

.animal-float {
  position: absolute;
  bottom: -80px;
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  animation: animal-up var(--duration) ease-in forwards;
  animation-delay: var(--delay);
}

.footer {
  width: min(1120px, 92vw);
  margin: 0 auto 1.6rem;
  color: #647789;
  font-size: 0.9rem;
  font-weight: 700;
}

.footer p {
  margin: 0.25rem 0;
}

.footer a {
  color: #4f6579;
}

.reveal {
  opacity: 0;
  transform: translateY(24px) scale(0.985);
  transition:
    transform 0.65s cubic-bezier(0.2, 0.65, 0.22, 1),
    opacity 0.65s ease;
  transition-delay: var(--delay, 0s);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.legal-page .topbar {
  margin-top: 1.2rem;
}

.legal-header {
  padding: 1.3rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--green-dark);
  font-weight: 800;
  margin-bottom: 0.6rem;
}

.legal-header p {
  color: var(--ink-soft);
  margin-bottom: 0;
}

.legal-section {
  padding: 1.2rem;
}

.legal-section ul,
.legal-section ol {
  margin: 0.25rem 0 0;
  padding-left: 1.2rem;
}

.legal-section li {
  margin: 0.32rem 0;
}

@keyframes blob-float {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-20px) scale(1.06);
  }
}

@keyframes hint-pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
    box-shadow:
      inset 0 -6px 0 #f9be00,
      0 0 0 6px rgba(255, 189, 0, 0.25);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes banner-drop {
  0% {
    opacity: 0;
    transform: translate(-50%, -35px) scale(0.92);
  }
  70% {
    opacity: 1;
    transform: translate(-50%, 6px) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}

@keyframes balloon-rise {
  0% {
    transform: translateY(0) translateX(0) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  50% {
    transform: translateY(-52vh) translateX(15px) rotate(4deg);
  }
  100% {
    transform: translateY(-114vh) translateX(-12px) rotate(-4deg);
    opacity: 0;
  }
}

@keyframes burst {
  0% {
    transform: translate(-50%, -50%) scale(0.35);
    opacity: 1;
  }
  100% {
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.05) rotate(220deg);
    opacity: 0;
  }
}

@keyframes animal-up {
  0% {
    transform: translateY(0) scale(0.85);
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  100% {
    transform: translateY(-84vh) scale(1.08);
    opacity: 0;
  }
}

@media (max-width: 980px) {
  .game-shell {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .topbar {
    border-radius: 20px;
    align-items: flex-start;
    gap: 0.6rem;
    flex-direction: column;
  }

  .menu {
    flex-wrap: wrap;
    gap: 0.45rem;
  }

  .btn {
    width: 100%;
  }

  .game-hud {
    grid-template-columns: 1fr;
  }
}
