@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&display=swap");

:root {
  /* Clean Light Theme Base */
  --bg-main: #fcfcfc;
  --bg-gradient: #f4f7fb;
  --card-bg: #ffffff;

  /* Bright Blue Accents */
  --primary: #0696cf;
  --primary-dark: #222222;
  --secondary: #4a5568;
  --accent: #0696cf;
  --border: rgba(0, 0, 0, 0.08);
  --shadow: 0 12px 35px rgba(0, 0, 0, 0.04); /* Softer shadow */

  /* Abacus Specific Colors */
  --frame-inner: #1e293b; /* Deep slate for the frame */
  --rod-color: #e2e8f0; /* Lighter metallic slate */
  --bead-heaven: #0696cf; /* New bright blue beads */
  --bead-earth: #ffffff; /* Clean white beads */
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  padding: 0;
  font-family: "Poppins", sans-serif;
  color: var(--secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 100px;
  min-height: 100vh;

  /* CLEAN BACKGROUND - Removed the dotted pattern */
  background-color: var(--bg-main);
}

/* Glassmorphism Back Button */
.back-refresh-btn {
  position: fixed;
  top: 80px;
  left: 15px;
  z-index: 1000;
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  color: var(--primary-dark);
  border: 1px solid var(--border);
  padding: 10px 18px;
  border-radius: 50px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.back-refresh-btn:hover {
  background: var(--primary);
  color: white;
}

/* Clean Flat Score Board */
.score-board {
  background: var(--card-bg);
  border: none; /* Removed glass border */
  padding: 30px 20px;
  border-radius: 20px; /* Squarer, flatter radius */
  box-shadow: var(--shadow);
  text-align: center;
  width: 95%;
  max-width: 500px;
  margin-bottom: 20px;
  z-index: 100;
}

.score-label {
  font-size: 0.85rem;
  color: var(--secondary);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.score-value {
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--primary-dark); /* Dark text for better contrast */
  margin: 0 0 15px 0;
}

.free-modules-container {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-bottom: 20px;
  width: 100%;
}

.module-btn {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 16px;
  padding: 12px 20px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--primary-dark);
  box-shadow: 0 4px 15px rgba(0, 86, 179, 0.05);
  border: 2px solid transparent;
  transition: all 0.3s ease;
  flex: 1;
  justify-content: center;
}

.module-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0, 86, 179, 0.15);
  border-color: var(--primary);
}

.module-icon-box {
  width: 35px;
  height: 35px;
  margin-right: 12px;
  border-radius: 50%;
  background-color: rgba(0, 86, 179, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.module-icon-box i {
  font-size: 16px;
  color: var(--primary);
  transition: color 0.3s ease;
}

.module-btn:hover .module-icon-box {
  background-color: var(--primary);
}
.module-btn:hover .module-icon-box i {
  color: white;
}

.module-btn-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary-dark);
  display: block;
}

.free-tag {
  display: block;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.btn {
  padding: 10px 18px;
  border-radius: 6px; /* Flatter squarer buttons */
  border: 1px solid #cbd5e1; /* Subtle gray border */
  background: transparent;
  color: var(--secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: "Poppins", sans-serif;
}

.btn:hover {
  background: #f8fafc;
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-2px);
}

.btn-clear {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: none; /* Flat look */
}

.btn-clear:hover {
  background: #057eb0; /* Darker blue on hover */
  color: white;
  border-color: #057eb0;
  box-shadow: 0 4px 12px rgba(6, 150, 207, 0.2);
}

.abacus-scroll-container {
  width: 100%;
  overflow: auto;
  max-height: 70vh;
  display: block;
  text-align: center;
  padding: 20px 0;
  -webkit-overflow-scrolling: touch;
}

.abacus-zoom-layer {
  display: inline-block;
  transition: transform 0.2s ease-out;
  padding: 80px;
  transform-origin: center center;
}

.abacus-frame {
  background-color: var(--frame-inner);
  padding: 15px;
  border-radius: 16px;
  display: flex;
  gap: 10px;
  position: relative;
  box-shadow: 0 15px 40px rgba(0, 20, 50, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.1);
}

.beam {
  position: absolute;
  left: 0;
  right: 0;
  top: 85px;
  height: 12px;
  background: #64748b;
  z-index: 5;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.rod {
  width: 46px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.rod::before {
  content: "";
  position: absolute;
  top: -10px;
  bottom: -10px;
  width: 6px;
  background: var(--rod-color);
  border-radius: 3px;
  box-shadow: inset -2px 0 3px rgba(0, 0, 0, 0.2);
}

.bead {
  width: 44px;
  height: 30px;
  border-radius: 14px;
  z-index: 10;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow:
    inset 0 4px 6px rgba(255, 255, 255, 0.4),
    inset 0 -4px 6px rgba(0, 0, 0, 0.2),
    0 4px 8px rgba(0, 0, 0, 0.4);
}

.bead.heaven {
  background: var(--bead-heaven);
  margin-bottom: 70px;
}

.bead.earth {
  background: var(--bead-earth);
  margin-top: 8px;
}

.rod .bead.earth:first-of-type {
  margin-top: 55px;
}

.bead.heaven.active {
  transform: translateY(35px);
}

.bead.earth.active {
  transform: translateY(-35px);
}

.rod-mark {
  position: absolute;
  top: 72px;
  width: 12px;
  height: 12px;
  background: #ef4444;
  border-radius: 50%;
  z-index: 20;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Glassmorphism About Section */
.about-container {
  width: 90%;
  max-width: 800px;
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  padding: 40px;
  margin: 40px auto;
  border-radius: 28px;
  text-align: center;
  box-shadow: var(--shadow);
}

.about-container h2 {
  color: var(--primary-dark);
  margin-bottom: 20px;
}

.about-container p {
  color: var(--text-light);
  line-height: 1.6;
}

@media (max-width: 600px) {
  .abacus-zoom-layer {
    padding: 20px 10px;
  }

  .score-board {
    padding: 15px;
    border-radius: 24px;
    margin-top: 5px;
    width: 92%;
  }

  .score-value {
    font-size: 2.5rem;
    margin-bottom: 10px;
  }

  .free-modules-container {
    flex-direction: row;
    gap: 8px;
    margin-bottom: 15px;
  }

  .module-btn {
    padding: 8px 5px;
    border-radius: 12px;
  }

  .module-icon-box {
    width: 28px;
    height: 28px;
    margin-right: 6px;
  }

  .module-icon-box i {
    font-size: 13px;
  }

  .free-tag {
    font-size: 0.65rem;
  }

  .module-btn-label {
    font-size: 0.8rem;
  }

  .controls {
    gap: 6px;
  }

  .btn {
    padding: 8px 4px;
    font-size: 0.75rem;
    flex: 1 1 calc(33% - 6px);
  }

  .about-container {
    padding: 25px 15px;
    border-radius: 24px;
    width: 92%;
  }
}

/* --- PREMIUM BACKGROUND ANIMATION --- */
.bg-animation {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1; /* Keeps it behind the abacus */
  overflow: hidden;
  pointer-events: none;
}

.math-shape {
  position: absolute;
  color: var(--primary);
  opacity: 0.2; /* Strict 20% opacity */
  bottom: -100px;
  animation: floatUp linear infinite;
}

@keyframes floatUp {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 0.2;
  }
  90% {
    opacity: 0.2;
  }
  100% {
    transform: translateY(-120vh) rotate(360deg);
    opacity: 0;
  }
}

/* Randomized floating speeds and positions */
.math-shape:nth-child(1) {
  left: 10%;
  font-size: 3rem;
  animation-duration: 25s;
  animation-delay: 0s;
}
.math-shape:nth-child(2) {
  left: 25%;
  font-size: 2rem;
  animation-duration: 20s;
  animation-delay: 5s;
}
.math-shape:nth-child(3) {
  left: 40%;
  font-size: 4rem;
  animation-duration: 35s;
  animation-delay: 2s;
}
.math-shape:nth-child(4) {
  left: 60%;
  font-size: 2.5rem;
  animation-duration: 22s;
  animation-delay: 8s;
}
.math-shape:nth-child(5) {
  left: 75%;
  font-size: 3.5rem;
  animation-duration: 30s;
  animation-delay: 4s;
}
.math-shape:nth-child(6) {
  left: 90%;
  font-size: 2rem;
  animation-duration: 18s;
  animation-delay: 1s;
}
