:root {
  --c1: #2e5077;
  --c2: #4da1a9;
  --c3: #79d7be;
  --c4: #f6f4f0;
  --ink: #f7fafc;
  --ink-dim: #c9d6e2;
  --ink-muted: #9fb2c4;
  --surface: rgba(10, 24, 36, 0.35);
  --surface-strong: rgba(10, 24, 36, 0.45);
  --panel-border: rgba(255, 255, 255, 0.18);
  --panel-divider: rgba(255, 255, 255, 0.1);
  --button-surface: rgba(8, 20, 30, 0.35);
  --button-border: rgba(255, 255, 255, 0.2);
  --accent: #f6c177;
  --accent-hover: #e8a84a;
  --accent-glow: rgba(246, 193, 119, 0.35);
  --accent-coral: #ff6b6b;
  --accent-coral-hover: #ff4d4d;
  --accent-orchid: #b79cff;
  --accent-orchid-hover: #9d7cff;
  --accent-copper: #d28b5c;
  --accent-copper-hover: #c7773f;
  --ring: rgba(246, 193, 119, 0.35);
  --shadow-1: 0 20px 45px rgba(10, 8, 28, 0.35);
  --shadow-2: 0 8px 20px rgba(10, 8, 28, 0.25);
}

@font-face {
  font-family: "JosefinSans";
  src: url(/fonts/JosefinSans-VariableFont_wght.ttf) format("truetype");
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "JosefinSans", sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--ink);
  background:
    radial-gradient(
      circle at 12% 14%,
      rgba(121, 215, 190, 0.35) 0%,
      rgba(121, 215, 190, 0) 45%
    ),
    radial-gradient(
      circle at 85% 18%,
      rgba(77, 161, 169, 0.35) 0%,
      rgba(77, 161, 169, 0) 42%
    ),
    radial-gradient(
      circle at 40% 90%,
      rgba(46, 80, 119, 0.42) 0%,
      rgba(46, 80, 119, 0) 52%
    ),
    linear-gradient(
      130deg,
      #223a57 0%,
      var(--c1) 30%,
      var(--c2) 62%,
      var(--c3) 86%,
      var(--c4) 100%
    );
  overflow-x: hidden;
  position: relative;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: -20vmax;
  pointer-events: none;
  z-index: -1;
  mix-blend-mode: normal;
}

body::before {
  background: conic-gradient(
    from 180deg at 50% 50%,
    rgba(121, 215, 190, 0.16),
    rgba(77, 161, 169, 0.2),
    rgba(46, 80, 119, 0.2),
    rgba(246, 244, 240, 0.12),
    rgba(121, 215, 190, 0.16)
  );
  display: none;
}

body::after {
  background: repeating-linear-gradient(
    120deg,
    rgba(255, 255, 255, 0.025) 0 2px,
    rgba(255, 255, 255, 0) 2px 16px
  );
  display: none;
}

.game {
  width: min(980px, 95vw);
  padding: clamp(1rem, 2.2vw, 2rem);
  position: relative;
  border-radius: 24px;
  background: linear-gradient(
    145deg,
    rgba(10, 24, 36, 0.64),
    rgba(46, 80, 119, 0.36)
  );
  border: 1px solid var(--panel-border);
  box-shadow:
    var(--shadow-1),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  backdrop-filter: none;
  animation: riseIn 900ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

h1 {
  display: flex;
  justify-content: center;
  text-align: center;
  color: var(--c4);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: clamp(2rem, 4.4vw, 3.3rem);
  font-weight: 740;
  text-shadow:
    0 3px 0 rgba(0, 0, 0, 0.2),
    0 0 26px rgba(121, 215, 190, 0.48);
  margin-bottom: 1.25rem;
  animation: none;
}

.game-stats {
  display: flex;
  justify-content: center;
  gap: 0.65rem;
  margin-bottom: 0.8rem;
}

.stat-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 0.32rem 0.7rem 0.19rem;
  background: var(--surface);
  box-shadow:
    inset 0 1px 0 var(--panel-divider),
    inset 0 -1px 0 rgba(255, 255, 255, 0.04);
}

.stat-label {
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.stat-value {
  font-size: 1.02rem;
  font-weight: 730;
  color: var(--ink);
  min-width: 2.5ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* #moveDisplay, #timerDisplay {
  color: var(--accent);
} */

.game-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(80px, 1fr));
  align-items: end;
  gap: clamp(1rem, 4vw, 2.8rem);
  width: 100%;
  padding: clamp(1rem, 2.8vw, 1.8rem);
  margin: 0.8rem 0 1.4rem;
  border-radius: 20px;
  border: 1px solid var(--panel-border);
  background: linear-gradient(
    180deg,
    rgba(10, 24, 36, 0.42),
    rgba(10, 24, 36, 0.28)
  );
  box-shadow:
    inset 0 1px 0 var(--panel-divider),
    inset 0 -1px 0 rgba(255, 255, 255, 0.05),
    var(--shadow-2);
  overflow: hidden;
}

.game-board::before {
  content: "";
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: 22px;
  height: 16px;
  border-radius: 99px;
  background: linear-gradient(
    90deg,
    rgba(46, 80, 119, 0.55),
    rgba(121, 215, 190, 0.55)
  );
  filter: none;
  opacity: 0.65;
}

.tower {
  width: min(46px, 12vw);
  height: min(360px, 55vh);
  justify-self: center;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.62),
      rgba(255, 255, 255, 0.18) 42%,
      rgba(46, 80, 119, 0.72) 100%
    ),
    linear-gradient(160deg, var(--c1), var(--c2));
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  padding-bottom: 14px;
  box-shadow:
    inset 0 0 14px rgba(255, 255, 255, 0.24),
    0 12px 30px rgba(20, 16, 40, 0.35);
  position: relative;
  overflow: visible;
  animation: none;
  transition:
    transform 250ms ease,
    box-shadow 250ms ease;
}

.tower:nth-child(2) {
  animation-delay: -2s;
}

.tower:nth-child(3) {
  animation-delay: -4s;
}

.tower:hover {
  transform: none;
  box-shadow:
    inset 0 0 14px rgba(255, 255, 255, 0.28),
    0 18px 34px rgba(20, 16, 40, 0.45);
}
/* 
.tower::before {
  content: "";
  position: absolute;
  top: -12px;
  width: 120%;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  filter: blur(1px);
} */

.disk {
  width: 60px;
  height: 30px;
  margin-top: 8px;
  cursor: grab;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.65);
  box-shadow:
    0 8px 14px rgba(19, 16, 37, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
  transition:
    transform 220ms ease,
    box-shadow 220ms ease;
  animation: none;
  position: relative;
}

.disk::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 12%;
  right: 12%;
  height: 35%;
  border-radius: 999px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.55),
    rgba(255, 255, 255, 0.1)
  );
  pointer-events: none;
}

.disk:active {
  cursor: grabbing;
}

#disk1 {
  width: 60px;
  background: linear-gradient(
    102deg,
    #ffe8c7 0%,
    var(--accent) 48%,
    var(--accent-hover) 100%
  );
  animation-delay: -0.2s;
}

#disk2 {
  width: 90px;
  background: linear-gradient(
    102deg,
    #ffd7d7 0%,
    var(--accent-coral) 50%,
    var(--accent-coral-hover) 100%
  );
  animation-delay: -0.6s;
}

#disk3 {
  width: 120px;
  background: linear-gradient(
    102deg,
    #e9deff 0%,
    var(--accent-orchid) 50%,
    var(--accent-orchid-hover) 100%
  );
  animation-delay: -1s;
}

#disk4 {
  background: linear-gradient(
    102deg,
    #f0caaa 0%,
    var(--accent-copper) 52%,
    var(--accent-copper-hover) 100%
  );
  animation-delay: -1.4s;
}

#disk5 {
  background: linear-gradient(
    110deg,
    var(--accent-copper) 0%,
    var(--accent) 35%,
    var(--accent-orchid) 70%,
    var(--accent-coral-hover) 100%
  );
  animation-delay: -1.8s;
}

.disk:hover {
  transform: translateY(-3px) scale(1.05);
  border-color: var(--accent);
  box-shadow:
    0 14px 20px rgba(19, 16, 37, 0.4),
    0 0 0 5px var(--ring),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

#winBanner {
  width: min(720px, 92%);
  max-width: 92%;
  position: absolute;
  left: 0;
  right: 0;
  top: clamp(5rem, 11vw, 6.2rem);
  margin-left: auto;
  margin-right: auto;
  z-index: 20;
  pointer-events: none;
  border-radius: 16px;
  border: 1px solid var(--panel-border);
  background: linear-gradient(
    120deg,
    rgba(77, 161, 169, 0.94),
    rgba(46, 80, 119, 0.92)
  );
  color: var(--c4);
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow:
    0 10px 24px rgba(46, 80, 119, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  margin-top: 0;
  animation: bannerPop 600ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.7rem;
  margin-top: 1.2rem;
}

button {
  font-family: "JosefinSans", sans-serif;
  border: 1px solid var(--button-border);
  padding: 0.78rem 1.05rem;
  border-radius: 999px;
  background: linear-gradient(
    120deg,
    rgba(8, 20, 30, 0.42),
    var(--button-surface),
    rgba(8, 20, 30, 0.3)
  );
  color: #f7fafc;
  font-size: clamp(0.95rem, 1.8vw, 1.08rem);
  letter-spacing: 0.03em;
  font-weight: 680;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease;
  box-shadow: 0 8px 18px rgba(14, 10, 30, 0.32);
  position: relative;
  overflow: hidden;
}

button::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    120deg,
    rgba(255, 255, 255, 0.22),
    rgba(255, 255, 255, 0)
  );
  transform: translateX(-100%);
  transition: transform 320ms ease;
}

button:hover {
  cursor: pointer;
  transform: translateY(-2px) scale(1.03);
  border-color: var(--accent);
  box-shadow:
    0 12px 22px rgba(14, 10, 30, 0.42),
    0 0 0 4px var(--accent-glow);
}

button:hover::before {
  transform: translateX(0%);
}

button:active {
  transform: translateY(1px) scale(0.99);
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.how-to-play-btn:hover {
  text-decoration-color: var(--accent);
  text-underline-offset: 0.15rem;
}

.jw-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  padding: clamp(1rem, 3vw, 2rem);
  background: radial-gradient(
    circle at center,
    rgba(121, 215, 190, 0.28),
    rgba(24, 40, 58, 0.72)
  );
  backdrop-filter: none;
  overflow: auto;
}

.jw-modal.open {
  display: grid;
  place-items: center;
  animation: fadeIn 240ms ease;
}

.jw-modal-body {
  width: min(560px, 92vw);
  padding: clamp(1rem, 2.8vw, 1.6rem);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: linear-gradient(
    160deg,
    rgba(255, 255, 255, 0.94),
    rgba(241, 248, 246, 0.94)
  );
  color: #21405f;
  box-shadow: 0 18px 36px rgba(16, 11, 36, 0.42);
  animation: modalRise 320ms cubic-bezier(0.16, 0.74, 0.24, 1);
}

.jw-modal h2 {
  font-size: clamp(1.45rem, 4.3vw, 1.8rem);
  color: var(--c1);
  margin-bottom: 0.8rem;
}

.jw-modal h3 {
  font-size: clamp(1.1rem, 3.6vw, 1.24rem);
  color: var(--c2);
  margin-top: 0.75rem;
  margin-bottom: 0.4rem;
}

.jw-modal p,
.jw-modal ol {
  font-size: clamp(0.95rem, 2.8vw, 1rem);
  color: #2f5a66;
  line-height: 1.48;
}

.jw-modal ol {
  margin-left: 1.2rem;
}

.jw-modal p strong {
  color: var(--c3);
}

#modalClose {
  margin-top: 0.9rem;
  margin-left: auto;
  display: block;
  background: linear-gradient(120deg, var(--c1), var(--c2), var(--c1));
}

body.jw-modal-open {
  overflow: hidden;
}

@keyframes auroraSpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes riseIn {
  from {
    transform: translateY(24px) scale(0.98);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes titlePulse {
  0%,
  100% {
    text-shadow:
      0 3px 0 rgba(0, 0, 0, 0.2),
      0 0 22px rgba(121, 215, 190, 0.38);
  }
  50% {
    text-shadow:
      0 3px 0 rgba(0, 0, 0, 0.2),
      0 0 32px rgba(121, 215, 190, 0.62);
  }
}

@keyframes towerFloat {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-5px);
  }
}

@keyframes diskSway {
  0%,
  100% {
    transform: translateX(0px);
  }
  50% {
    transform: translateX(1.5px);
  }
}

@keyframes bannerPop {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes bannerGlow {
  0%,
  100% {
    box-shadow:
      0 10px 24px rgba(46, 80, 119, 0.45),
      inset 0 1px 0 rgba(255, 255, 255, 0.3);
  }
  50% {
    box-shadow:
      0 14px 32px rgba(77, 161, 169, 0.52),
      inset 0 1px 0 rgba(255, 255, 255, 0.3);
  }
}

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

@keyframes modalRise {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 900px) {
  .game {
    width: min(680px, 95vw);
    padding: 1rem;
  }

  .game-board {
    gap: 1rem;
  }

  .tower {
    height: min(330px, 48vh);
  }

  button {
    padding: 0.66rem 0.9rem;
  }
}

@media (max-width: 640px) {
  body {
    align-items: flex-start;
    padding: 1rem 0;
  }

  .game {
    border-radius: 18px;
    margin: 0.25rem;
  }

  .game-stats {
    gap: 0.45rem;
    margin-bottom: 0.6rem;
  }

  .stat-pill {
    padding: 0.3rem 0.6rem 0.16rem;
  }

  .stat-label {
    font-size: 0.72rem;
  }

  .stat-value {
    font-size: 0.96rem;
  }

  .game-board {
    padding: 0.8rem;
    gap: 0.6rem;
  }

  .tower {
    width: min(32px, 10vw);
    height: min(275px, 43vh);
    padding-bottom: 10px;
  }

  .disk {
    margin-top: 6px;
    height: 24px;
  }

  #disk1 {
    width: 48px;
  }
  #disk2 {
    width: 72px;
  }
  #disk3 {
    width: 96px;
  }
  #disk4 {
    width: 118px;
  }
  #disk5 {
    width: 140px;
  }

  .controls {
    gap: 0.45rem;
  }

  button {
    width: calc(50% - 0.25rem);
    min-width: 148px;
    font-size: 0.94rem;
  }

  .jw-modal {
    padding: 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
