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

:root {
  /* SpeedoMaths Brand Colors */
  --bg-main: #fcfcfc;
  --bg-gradient: #f8f9fa;
  --card-bg: #ffffff;

  /* SpeedoMaths Red Accents replacing Blue/Teal */
  --primary: #d72217;
  --primary-dark: #191919;
  --secondary: #4a5568;
  --primary-gradient: linear-gradient(to bottom right, #d72217, #7a0f0a);
  --accent: #d72217;

  /* Glass Navbar */
  --header-bg: #ffffff;
  --header-height: 80px;

  /* Accents & Borders */
  --border: rgba(0, 0, 0, 0.08);
  --shadow: 0 4px 15px rgba(0, 0, 0, 0.05);

  /* Status Colors */
  --success-color: #00a859;
  --error-color: #e63946;
  --bar-bg: #f8fafc;
  --gray-btn: #f1f5f9;

  /* Abacus Colors */
  --abacus-frame: #191919; /* Sleek black frame */
  --abacus-board: #ffffff;
  --bead-color: #d72217; /* Primary red beads */
  --bead-border: #7a0f0a;
  --bead-hover: #ff4d42;
}

body {
  font-family: "Poppins", sans-serif;
  color: var(--text-dark);
  margin: 0;
  padding: 0;
  padding-top: 100px; /* Extra space for floating header */

  /* Soft vignette background to reduce eye strain */
  background: radial-gradient(circle at top center, #ffffff 0%, #f0f4f9 120%);
  background-attachment: fixed;
}

/* Subtle paper texture overlay */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -2;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  opacity: 0.04;
}

/* --- HEADER --- */
header {
  position: fixed;
  top: 15px;
  left: 5%;
  width: 90%;
  height: 70px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  border-radius: 50px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
  z-index: 1000;
  box-sizing: border-box;
}

.logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffffff;
  background: var(--primary);
  padding: 6px 16px;
  border-radius: 10px;
  letter-spacing: normal;
  text-transform: none;
}

.nav-links {
  display: flex;
  gap: 20px;
}
.nav-links a {
  text-decoration: none;
  color: var(--text-light);
  font-weight: 600;
  font-size: 0.95rem;
  transition: color 0.2s;
}
.nav-links a:hover {
  color: var(--primary);
}

@media (max-width: 600px) {
  .nav-links {
    display: none;
  }
  .logo {
    font-size: 1.2rem;
  }
}

/* --- MAIN LAYOUT --- */
.app-container {
  max-width: 1200px;
  margin: 20px auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 30px;
  align-items: start;
  position: relative;
  z-index: 1;
}
.app-container::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 140%;
  height: 140%;
  background: radial-gradient(
    circle,
    rgba(215, 34, 23, 0.04) 0%,
    transparent 60%
  );
  z-index: -1;
  pointer-events: none;
}

@media (max-width: 900px) {
  .app-container {
    grid-template-columns: 1fr;
    padding: 0 15px;
  }
}

/* --- SIDE PANEL (QUESTIONS & SETTINGS) --- */
.side-panel {
  background: #ffffff;
  padding: 40px;
  border-radius: 16px;
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.08),
    0 0 0 1px rgba(0, 0, 0, 0.02);
  position: relative;
  overflow: hidden;
}

.side-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--primary-gradient);
}

.settings-row {
  display: flex;
  gap: 20px;
  margin-bottom: 25px;
  padding-bottom: 0;
  border-bottom: none; /* Removed dashed line for cleaner look */
}

.question-box {
  background: rgba(215, 34, 23, 0.02);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  font-size: 2.2rem;
  font-weight: 700;
  font-family: "Poppins", sans-serif;
  text-align: right;
  margin-bottom: 20px;
  min-height: 200px;
}
input[type="number"] {
  width: 100%;
  padding: 8px 0;
  border: none;
  border-bottom: 1px solid #cbd5e1;
  border-radius: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary-dark);
  background: rgba(215, 34, 23, 0.03);
  outline: none;
  transition: border-color 0.3s ease;
}

input[type="number"]:focus {
  border-bottom: 2px solid var(--primary);
}

label {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--primary);
  font-size: 0.75rem;
  margin-bottom: 8px;
  display: block;
}

input[type="number"] {
  width: 100%;
  padding: 8px 0;
  border: none;
  border-bottom: 1px solid #cbd5e1; /* Thin bottom border only */
  border-radius: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-dark);
  outline: none;
  background: transparent;
  transition: border-color 0.3s ease;
}

input[type="number"]:focus {
  border-bottom: 2px solid var(--primary);
}

.question-box {
  background: #f8fafc;
  border: 2px solid var(--primary);
  border-radius: 12px;
  padding: 20px;
  font-size: 1.8rem;
  font-weight: bold;
  font-family: monospace;
  text-align: right;
  margin-bottom: 20px;
  min-height: 200px;
}

.seq-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
  letter-spacing: 2px;
}

.seq-line {
  border-top: 3px solid var(--text-dark);
  margin-top: 10px;
  padding-top: 10px;
}

.btn {
  width: 100%;
  padding: 14px 24px;
  border: none;
  border-radius: 6px; /* Squarer, modern corners */
  font-family: "Poppins", sans-serif;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  color: white;
  transition: all 0.3s ease;
  margin-bottom: 10px;
  box-shadow: none; /* Flat look */
}

.btn-check,
.btn-next {
  background: var(--primary-gradient);
  box-shadow: 0 4px 10px rgba(215, 34, 23, 0.2);
}

.btn-check:hover,
.btn-next:hover {
  background: linear-gradient(to top left, #d72217, #7a0f0a);
  box-shadow: 0 6px 15px rgba(215, 34, 23, 0.35);
  transform: translateY(-2px);
}

.bead.active {
  background: #ff4d42; /* Bright glowing red */
  border-color: var(--bead-border);
  box-shadow:
    inset -3px -3px 6px rgba(0, 0, 0, 0.1),
    0 0 12px 4px rgba(215, 34, 23, 0.5); /* Red glow effect */
}

.btn-skip {
  background: #f1f5f9;
  color: var(--text-dark);
  border: 1px solid #cbd5e1;
}

.btn-skip:hover {
  background: #e2e8f0;
}

#feedback {
  text-align: center;
  font-weight: bold;
  font-size: 1.2rem;
  margin-top: 10px;
  min-height: 30px;
}

/* =========================================
         ABACUS CSS STYLES (Modern Blue Theme)
         ========================================= */
.abacus-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.abacus-container {
  display: inline-flex;
  background: var(--abacus-board);
  border: 12px solid var(--abacus-frame); /* Thinner, sleeker frame */
  padding: 10px 15px; /* Reduced padding */
  border-radius: 8px; /* Sharper corners */
  box-shadow:
    inset 0 5px 15px rgba(0, 0, 0, 0.1),
    0 15px 30px rgba(0, 0, 0, 0.15);
  gap: 10px; /* Reduced gap between columns */
  position: relative; /* For absolute positioning of the beam */
}

.abacus-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  width: 65px;
}

.abacus-col::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 6px;
  background: #94a3b8;
  transform: translateX(-50%);
  z-index: 0;
  border-radius: 3px;
}

.beam {
  width: 100%;
  height: 18px;
  background: var(--abacus-frame);
  z-index: 1;
  margin: 8px 0;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
  border-radius: 2px;
}

.bead {
  width: 55px;
  height: 30px;
  border-radius: 15px;
  background: var(--bead-color);
  border: 2px solid var(--bead-border);
  z-index: 2;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow:
    inset -3px -3px 6px rgba(0, 0, 0, 0.2),
    0 4px 5px rgba(0, 0, 0, 0.2);
}
.bead:hover {
  background: var(--bead-hover);
}

.upper-deck {
  height: 70px;
  display: flex;
  align-items: flex-start;
  width: 100%;
  justify-content: center;
}
.upper-deck .bead.active {
  transform: translateY(30px);
}

.bead.active {
  background: #60a5fa; /* A brighter, glowing blue */
  border-color: #3b82f6;
  box-shadow:
    inset -3px -3px 6px rgba(0, 0, 0, 0.1),
    0 0 12px 4px rgba(96, 165, 250, 0.6); /* Adds the glow effect */
}
.lower-deck {
  height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  width: 100%;
  align-items: center;
  gap: 8px;
}
.lower-deck .bead.active {
  transform: translateY(-38px);
}

.live-value {
  margin-top: 20px;
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--text-light);
  background: white;
  padding: 10px 20px;
  border-radius: 50px;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.05);
}

/* --- MOBILE ABACUS SCALING --- */
@media (max-width: 600px) {
  .abacus-container {
    border-width: 10px;
    padding: 8px;
    gap: 6px;
  }
  .abacus-col {
    width: 40px;
  }
  .abacus-col::before {
    width: 4px;
  }
  .beam {
    height: 12px;
    margin: 5px 0;
  }
  .bead {
    width: 34px;
    height: 18px;
    border-radius: 9px;
    border-width: 1px;
  }
  .upper-deck {
    height: 45px;
  }
  .upper-deck .bead.active {
    transform: translateY(24px);
  }

  .lower-deck {
    height: 120px;
    gap: 5px;
  }
  .lower-deck .bead.active {
    transform: translateY(-22px);
  }

  .question-box {
    font-size: 1.5rem;
    min-height: 150px;
  }
}
