/* ============================================================
   RESET & ROOT
   ============================================================ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --font: 'Fredoka One', 'Nunito', cursive, sans-serif;
  --font-body: 'Nunito', sans-serif;
  --transition-bounce: 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  --transition-fast: 0.15s ease;
  --modal-duration: 3000ms;
}

/* ============================================================
   BACKGROUND & BODY
   ============================================================ */
body {
  font-family: var(--font);
  min-height: 100vh;
  padding: 16px 16px 60px;
  overflow-x: hidden;
  background-color: #1a0533;
  background-image:
    radial-gradient(ellipse at 15% 20%, #ff6b9d55 0%, transparent 50%),
    radial-gradient(ellipse at 85% 15%, #4ecdc455 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, #ffd93d33 0%, transparent 55%),
    radial-gradient(ellipse at 80% 75%, #6c5ce755 0%, transparent 45%);
}

/* Floating background stars */
body::before {
  content: '✦ ✧ ✦ ✧ ✦ ✧ ✦ ✧ ✦ ✧ ✦ ✧ ✦';
  position: fixed;
  top: 0; left: 0; right: 0;
  font-size: 1.4rem;
  color: rgba(255,255,255,0.06);
  letter-spacing: 3vw;
  word-spacing: 4vw;
  line-height: 4;
  pointer-events: none;
  z-index: 0;
  white-space: normal;
  padding: 20px;
}

/* ============================================================
   HEADER
   ============================================================ */
header {
  text-align: center;
  padding: 32px 16px 24px;
  position: relative;
  z-index: 1;
}

h1 {
  font-family: var(--font);
  font-size: clamp(2rem, 7vw, 3.8rem);
  color: #fff;
  text-shadow:
    3px 3px 0 #e040fb,
    6px 6px 0 rgba(0,0,0,0.25);
  letter-spacing: 1px;
  line-height: 1.15;
}

.subtitle {
  font-family: var(--font-body);
  font-size: clamp(0.95rem, 2.5vw, 1.25rem);
  color: rgba(255,255,255,0.8);
  margin-top: 10px;
  font-weight: 700;
}

/* ============================================================
   MAIN & SECTIONS
   ============================================================ */
main {
  max-width: 920px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

section {
  margin-bottom: 44px;
  background: rgba(255,255,255,0.06);
  border-radius: 24px;
  padding: 24px 20px;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.1);
}

.section-title {
  font-family: var(--font);
  font-size: clamp(1.3rem, 4vw, 1.9rem);
  color: #fff;
  text-shadow: 1px 2px 6px rgba(0,0,0,0.4);
  margin-bottom: 18px;
}

/* ============================================================
   GRIDS
   ============================================================ */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
  gap: 10px;
}

.numbers-grid {
  grid-template-columns: repeat(auto-fill, minmax(82px, 1fr));
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  position: relative;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 2rem;
  color: #fff;
  text-shadow: 1px 2px 4px rgba(0,0,0,0.25);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  transition:
    transform var(--transition-bounce),
    box-shadow var(--transition-fast),
    filter var(--transition-fast);
  /* bottom shadow gives a "physical button" feel */
  box-shadow: 0 6px 0 var(--btn-shadow, rgba(0,0,0,0.25)), 0 8px 20px rgba(0,0,0,0.2);
  outline: none;
  overflow: hidden;
}

/* Shine overlay */
.btn::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 45%;
  background: linear-gradient(to bottom, rgba(255,255,255,0.28), transparent);
  border-radius: 16px 16px 50% 50%;
  pointer-events: none;
}

.btn:hover {
  transform: translateY(-5px) scale(1.1);
  box-shadow: 0 10px 0 var(--btn-shadow, rgba(0,0,0,0.25)), 0 16px 28px rgba(0,0,0,0.3);
  filter: brightness(1.1);
}

.btn:active,
.btn.active {
  transform: translateY(3px) scale(0.95);
  box-shadow: 0 2px 0 var(--btn-shadow, rgba(0,0,0,0.25)), 0 4px 10px rgba(0,0,0,0.2);
  filter: brightness(0.95);
}

.btn-number {
  font-size: 2.2rem;
  border-radius: 20px;
}

.btn-number::before {
  border-radius: 20px 20px 50% 50%;
}

/* ============================================================
   OVERLAY & MODAL
   ============================================================ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 5, 30, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: #fff;
  border-radius: 28px;
  padding: 44px 48px 36px;
  box-shadow:
    0 0 0 3px rgba(255,255,255,0.15),
    0 24px 80px rgba(0,0,0,0.4);
  text-align: center;
  position: relative;
  width: min(520px, calc(100vw - 32px));
  overflow: hidden;
  transform: scale(0.4) rotate(-8deg);
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.overlay.active .modal {
  transform: scale(1) rotate(0deg);
}

/* Close button */
.close-btn {
  position: absolute;
  top: 14px;
  right: 16px;
  background: #f0f0f4;
  border: none;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  font-size: 1rem;
  cursor: pointer;
  color: #999;
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  z-index: 2;
}

.close-btn:hover {
  background: #ff6b6b;
  color: #fff;
  transform: scale(1.15) rotate(90deg);
}

/* Large character display */
.modal-char {
  font-family: var(--font);
  font-size: clamp(4rem, 12vw, 6rem);
  line-height: 1;
  margin-bottom: 28px;
  /* color set by JS */
}

/* Images container */
.modal-images {
  display: flex;
  gap: 20px;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
}

.image-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.image-box img {
  width: 150px;
  height: 150px;
  object-fit: contain;
  border-radius: 16px;
  background: #f4f4ff;
  border: 3px solid #ebebf5;
  padding: 10px;
  transition: transform var(--transition-bounce);
}

.image-box img:hover {
  transform: scale(1.05);
}

.image-box.single img {
  width: 190px;
  height: 190px;
}

.image-label {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 900;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

/* ============================================================
   PROGRESS BAR (auto-close indicator)
   ============================================================ */
.progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 7px;
  background: linear-gradient(90deg, #ff6b9d, #ffd93d, #4ecdc4, #6c5ce7);
  transform-origin: left center;
  transform: scaleX(0);
  border-radius: 0 0 28px 28px;
}

.progress-bar.running {
  animation: progress-shrink var(--modal-duration) linear forwards;
}

@keyframes progress-shrink {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

/* ============================================================
   PARTICLES
   ============================================================ */
.particle {
  position: fixed;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  animation: particle-burst 0.75s ease-out forwards;
}

@keyframes particle-burst {
  0%   { transform: translate(0, 0) scale(1);   opacity: 1; }
  100% { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; }
}

/* ============================================================
   RESPONSIVE — TABLET
   ============================================================ */
@media (max-width: 700px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
    gap: 8px;
  }
  .numbers-grid {
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  }
  .btn { font-size: 1.7rem; }
  .modal { padding: 36px 28px 32px; }
  .image-box img { width: 120px; height: 120px; }
  .image-box.single img { width: 155px; height: 155px; }
}

/* ============================================================
   RESPONSIVE — MOBILE
   ============================================================ */
@media (max-width: 420px) {
  body { padding: 10px 10px 50px; }
  h1 { font-size: 1.8rem; }
  section { padding: 16px 12px; }
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 6px;
  }
  .numbers-grid {
    grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
  }
  .btn { font-size: 1.45rem; border-radius: 12px; }
  .btn::before { border-radius: 12px 12px 50% 50%; }
  .modal { padding: 32px 18px 28px; }
  .modal-char { font-size: 3.5rem; margin-bottom: 20px; }
  .modal-images { gap: 12px; }
  .image-box img { width: 105px; height: 105px; }
  .image-box.single img { width: 140px; height: 140px; }
  .image-label { font-size: 0.75rem; }
}
