@import url("https://fonts.googleapis.com/css2?family=Sora:wght@400;600;700;800&family=DM+Sans:wght@400;500;600&display=swap");

:root {
  /* Light Theme Base */
  --bg-main: #ffffff;
  --bg-gradient: #e2eefb;
  --card-bg: rgba(255, 255, 255, 0.75);

  /* Blue Accents replacing Green */
  --primary: #0056b3;
  --primary-dark: #0a192f;
  --secondary: #1e293b; /* Dark text for light background */

  /* Glass Navbar */
  --header-bg: rgba(255, 255, 255, 0.85);
  --header-height: 70px;

  /* Accents & Borders */
  --accent: #0056b3;
  --border: rgba(0, 86, 179, 0.15);
  --shadow: 0 8px 32px rgba(0, 40, 90, 0.05);

  /* Status Colors */
  --success-color: #00a859;
  --error-color: #e63946;
  --bar-bg: rgba(0, 86, 179, 0.08);
  --gray-btn: rgba(0, 86, 179, 0.1);
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  padding: 0;
  font-family: "DM Sans", sans-serif;
  color: var(--secondary);
  padding-top: calc(var(--header-height) + 60px);
  min-height: 100vh;
  overflow-x: hidden;

  /* PREMIUM MICRO-DOT PATTERN */
  background-color: var(--bg-main);
  background-image:
    radial-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(135deg, var(--bg-main) 0%, var(--bg-gradient) 100%);
  background-size:
    20px 20px,
    100% 100%;
  background-attachment: fixed;
}

header {
  background: var(--header-bg);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 1000;
  box-sizing: border-box;
  box-shadow: 0 4px 20px rgba(0, 86, 179, 0.05);
}

.logo {
  height: 35px;
  background: var(--primary);
  color: white;
  padding: 4px 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  font-family: "Sora", sans-serif;
  font-weight: 800;
  text-decoration: none;
}

.nav-links {
  display: none;
  gap: 30px;
  align-items: center;
}

.nav-links a {
  color: var(--primary-dark);
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 1px;
  text-decoration: none;
  font-weight: 700;
  transition: color 0.3s ease;
}

.nav-links a:hover {
  color: var(--accent);
}

@media (max-width: 600px) {
  .nav-links {
    display: none;
  }
}

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 20px;
  position: relative;
  z-index: 1;
}

/* Glassmorphism Card */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 28px;
  padding: 30px 20px;
  box-shadow: var(--shadow);
  text-align: left;
}

h2 {
  color: var(--primary-dark);
  margin-bottom: 40px;
  font-size: 2.5rem;
  font-family: "Sora", sans-serif;
  display: inline-block;
  border-bottom: 4px solid var(--accent);
  padding-bottom: 5px;
}

.input-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 15px;
  margin-bottom: 20px;
  text-align: left;
}

label {
  display: block;
  margin-bottom: 5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  font-size: 0.85rem;
}

input[type="number"] {
  width: 100%;
  padding: 10px 0;
  border: none;
  border-bottom: 2px solid rgba(0, 86, 179, 0.2);
  background-color: transparent;
  border-radius: 0;
  font-size: 1.3rem;
  font-weight: 600;
  outline: none;
  transition: all 0.3s ease;
  color: var(--primary-dark);
}

input[type="number"]:focus {
  border-bottom: 2px solid var(--primary);
  box-shadow: none;
}

.stats-bar {
  display: flex;
  justify-content: space-between;
  background: var(--bar-bg);
  padding: 12px 20px;
  border-radius: 12px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 30px;
  font-size: 1rem;
  border: 1px solid var(--border);
}

.score-badges {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 20px;
}

.badge {
  padding: 8px 25px;
  border-radius: 50px;
  font-size: 0.95rem;
  font-weight: 800;
  color: white;
}

.badge-green {
  background-color: var(--success-color);
}

.badge-red {
  background-color: var(--error-color);
}

.question-box {
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--primary-dark);
  margin: 20px 0;
  min-height: 80px;
  text-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

#user-ans {
  text-align: center;
  font-size: 2rem;
  font-weight: bold;
  width: 80%;
  margin: 15px auto 30px auto;
  letter-spacing: 1px;
  padding: 15px;
  border-radius: 16px;
  background: rgba(0, 86, 179, 0.05);
  border: 1px solid var(--border);
  color: var(--primary-dark);
}

#user-ans::placeholder {
  color: rgba(0, 86, 179, 0.3);
}

.result-bubble {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 15px 40px;
  border-radius: 50px;
  background: var(--accent);
  color: white;
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 30px;
  box-shadow: 0 8px 25px rgba(0, 86, 179, 0.3);
}

.btn {
  width: 100%;
  min-width: unset;
  padding: 16px 20px;
  border: none;
  border-radius: 50px;
  font-family: "Sora", sans-serif;
  font-size: 1.05rem;
  font-weight: 800;
  color: white;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  display: block;
  margin: 0 auto 15px auto;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

/* Solid Blue Primary Button */
.btn-check {
  background: var(--primary);
  color: white;
  box-shadow: 0 8px 25px rgba(0, 86, 179, 0.3);
}

.btn-check:hover {
  background: #004494;
  box-shadow: 0 12px 35px rgba(0, 86, 179, 0.4);
}

.btn-check:active {
  transform: translateY(2px);
}

.btn-restart {
  background: var(--gray-btn);
  color: var(--primary-dark);
  border: 1px solid var(--border);
}

.btn-restart:hover {
  background: rgba(0, 86, 179, 0.15);
}

.btn-stop {
  background: transparent;
  color: var(--error-color);
  border: 2px solid var(--error-color);
}

.btn-stop:hover {
  background: var(--error-color);
  color: white;
}

.feedback-text {
  font-size: 1.2rem;
  font-weight: 700;
  min-height: 30px;
  margin-bottom: 15px;
  color: var(--primary-dark);
}

.settings-box {
  background: rgba(0, 86, 179, 0.03);
  padding: 20px;
  border-radius: 20px;
  margin-bottom: 35px;
  border: 1px solid var(--border);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-row input[type="checkbox"] {
  accent-color: var(--accent);
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.checkbox-row label {
  margin: 0;
  cursor: pointer;
  font-weight: 600;
  color: var(--primary-dark);
  text-transform: none;
  font-size: 1rem;
}

#auto-options {
  display: none;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid var(--border);
}

.back-refresh-btn {
  position: fixed;
  top: 85px;
  left: 20px;
  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;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#countdown-text {
  height: 30px;
  color: var(--accent);
  font-weight: 800;
  font-size: 1.2rem;
  margin-bottom: 10px;
}

@media (min-width: 600px) {
  header {
    padding: 0 40px;
  }

  .nav-links {
    display: flex;
  }

  .input-grid {
    grid-template-columns: 1fr 1fr;
    gap: 20px;
  }

  .btn {
    width: auto;
    min-width: 250px;
  }
}

#game-screen .card,
#flash-screen .card,
#answer-screen .card {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#flash-display {
  font-size: 5rem;
  font-weight: 800;
  color: var(--primary-dark);
  margin: 20px 0;
  min-height: 100px;
  line-height: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  text-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

/* --- BACKGROUND ANIMATION --- */
.bg-animation {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.math-shape {
  position: absolute;
  color: var(--primary);
  opacity: 0.2;
  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;
  }
}

.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;
}

/* --- STEP INDICATOR UI --- */
.step-indicator {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-bottom: 30px;
}

.step-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bar-bg);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.step-dot.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

.step-line {
  height: 2px;
  width: 25px;
  background: var(--bar-bg);
}

.btn-group {
  display: flex;
  gap: 10px;
}

.btn-secondary {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}
