/* Layout / typography */
body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-family: 'Press Start 2P', monospace;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  background: #15171c;
  color: #c4f2f2
}

/* Vertical layout for factoring game */
body.factoring #answerGrid {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 0.6rem;
  width: 100%;
  max-width: 500px;
  margin: 1rem auto;
  align-items: stretch;
  /* a bit wider since expressions are long */
}

body.factoring #answerGrid button {
  flex: 1 1 auto;
  width: 100%;
  text-align: center;
  padding: 1rem 0.8rem;
}

h1 {
  margin: 0.5rem 0;
  font-size: 3rem;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* push title left, logo right */
  width: 100%;
  max-width: 920px;
  /* same as your section width for balance */
  margin-bottom: 0;
}

.site-header .logo {
  width: 128px;
  height: 128px;
  object-fit: contain;
}

.site-header h1 {
  margin: 0;
  font-size: 2rem;
}

#question {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  margin: 1rem 0;
  text-align: center;
}

/* Apply retro font only to game elements */
#question,
#answer,
#answerGrid button,
.btn-clear-inline,
.numpad button {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.9rem;
  /* smaller so it fits */
  line-height: 1.2;
  /* tighter line spacing */
}

#question {
  font-size: 1.5rem;
  /* override for question */
  font-weight: 700;
  letter-spacing: 0.5px;
}


/* Seamless input + clear button group */
.answer-group {
  display: inline-flex;
  align-items: stretch;
  /*border: 1px solid #aac3c6;* /
  /*border-radius: 10px;*/
  background: #312c2c;
  /* same as your input bg */
  overflow: hidden;
  /* clip inner corners */
  margin-bottom: 1rem;
  /* replaces old #answer margin */
}

/* Let the group own the border/radius; input becomes flat inside */
.answer-group #answer {
  border: 0;
  border-radius: 0;
  margin: 0;
  /* kill existing bottom margin */
  background: transparent;
  /* inherit group bg */
  color: #b7f7b7;
  font-size: 1.5rem;
  /* keep your current size */
  text-align: center;
  width: 8ch;
  padding: 0.35rem 0.75rem;
  /* vertical height control */
  line-height: 1.2;
}

/* Inline clear matches height and rounds on the right */
.answer-group .btn-clear-inline {
  border: 0;
  /* divider between input and button */
  background: #5a1e1e;
  color: #fff;
  font-weight: 700;
  padding: 0 0.8rem;
  /* no vertical padding needed; group controls height */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Hover/focus states */
.answer-group .btn-clear-inline:hover {
  background: #822;
}

.answer-group:focus-within {
  box-shadow: 0 0 0 2px rgba(183, 247, 183, 0.15) inset;
}

/* Keep your existing "wrong" feedback effect working */
#answer.wrong {
  background: #de6b6b;
  /* will fill the left side of the pill */
  border-color: transparent;
}

#answer {
  font-size: 1.5rem;
  text-align: center;
  width: 8ch;
  padding: 0.35rem 0.5rem;
  margin-bottom: 1rem;
  border-radius: 10px;
  background: #312c2c;
  color: #b7f7b7;
}

#answer.wrong {
  background: #de6b6b;
  border-color: #282222;
}

/* brief success flash */
#answer.correct {
  background: #1e5a1e;
  border-color: #1e5a1e;
  color: #fff;
}

/* Responsive numpad */
.numpad {
  display: grid;
  grid-template-columns: repeat(3, minmax(64px, 1fr));
  gap: 10px;
  margin-bottom: 1rem;
  width: 100%;
  max-width: 320px;
}

.numpad button {
  font-size: 1.4rem;
  padding: 0.9rem;
  border-radius: 12px;
  background: #363f50;
  border: none;
  user-select: none;
  color: #c0f2ae;
}

.numpad button.active {
  background: #b7f7b7;
}

/* flash green */

/* Special styles for Clear and Enter */
.numpad .btn-clear {
  background: #5a1e1e;
  /* deep red */
  color: #fff;
  font-weight: bold;
}

.numpad .btn-clear:hover {
  background: #822;
  /* lighter red */
}

.numpad .btn-enter {
  background: #1e5a1e;
  /* deep green */
  color: #fff;
  font-weight: bold;
}

.numpad .btn-enter:hover {
  background: #2d7d2d;
  /* lighter green */
}

.numpad .btn-neg {
  background: #333366;
  /* bluish */
  color: #fff;
  font-weight: bold;
}

.numpad .btn-neg:hover {
  background: #5555aa;
}

#feedback {
  font-size: 1.1rem;
  min-height: 1.2rem;
  margin-top: 0.25rem;
  text-align: center;
}

.numpad button,
#answerGrid button,
#negToggle {
  touch-action: manipulation;
}

/* Landing menu */
.menu {
  display: grid;
  grid-template-columns: minmax(200px, 320px);
  gap: 12px;
  margin-top: 2rem;
  width: 100%;
  justify-content: center;
}

.menu a {
  display: flex;
  flex-direction: column;
  text-align: center;
  justify-content: center;
  padding: 1rem;
  border-radius: 12px;
  background: #211d1d;
  border: 1px solid #635c5c;
  font-size: 1.1rem;
  text-decoration: none;
  color: #cce4ed;
  transition: background 0.15s ease;
}

.menu a:hover {
  background: #5a80a3;
}


/* --- Choice grid shell (unit circle, etc.) --- */
.choice-wrap {
  display: grid;
  gap: 0.8rem;
  justify-items: center;
}

/* Responsive sizing for the SVG circle board: near-full width on phones, capped on desktop */
.circle-svg {
  /* ~90% viewport width on phones; cap on desktop */
  width: min(90vw, 600px);
  height: auto;
  display: block;
  margin-bottom: 0.8rem; /* add breathing room above stats */
}

#answerGrid {
  /* Use flex so incomplete rows center nicely */
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
  margin: 1rem auto;
  width: 100%;
  max-width: 420px;
}

#answerGrid button {
  font-size: 1.2rem;
  border-radius: 10px;
  border: 1px solid #1e2222;
  background: #262424;
  color: #e9e2e2;
  padding: 1rem 0.8rem;
  user-select: none;
  transition: background 0.15s ease;
  /* Force three columns while allowing wrap; center incomplete rows */
  box-sizing: border-box;
  flex: 0 0 calc((100% - 1.2rem) / 3); /* 2 gaps of 0.6rem per row */
  text-align: center;
}

#answerGrid button.active {
  background: #b7f7b7;
}

#answerGrid button.wrong {
  background: #f28a8a;
}

/* Dynamic choices (factoring) - column layout */
#answerGrid.dynamic-choices {
  display: flex !important;
  flex-direction: column !important;
  flex-wrap: nowrap !important;
  gap: 0.6rem !important;
  width: 100% !important;
  max-width: 500px !important;
  margin: 1rem auto !important;
  align-items: stretch !important;
  justify-content: center !important; /* reset */
}

#answerGrid.dynamic-choices button {
  flex: 0 0 auto !important; /* reset from calc */
  width: 100% !important;
  text-align: center !important;
  padding: 1rem 0.8rem !important;
}

#negToggle {
  font-weight: 700;
  font-size: 1.4rem;
  background: #c0f2ae;
  color: #e3e9e4;
  border: 1px solid #444;
}

#negToggle.active {
  background: #4caf50;
  color: #fff;
}

#feedback, 
#stats {
  text-align: center;
}

/* Hide textual feedback; rely on visual cues instead */
#feedback { display: none; }

/* Progress bar for leveled games */
.progress-bar {
  position: relative;
  width: 100%;
  max-width: 320px;
  height: 2rem;
  margin: 0.5rem auto;
  background: #312c2c;
  border: none;
  border-radius: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: #009dff; /* Solid color for iOS Safari compatibility */
  width: 0%;
  /* Removed transition for iOS Safari compatibility */
}

.progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.9rem;
  font-weight: bold;
  color: #fff;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.7);
  pointer-events: none;
}

/* Small red level indicator for arithmetic games */
.level-indicator {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: #ff6b6b; /* soft red */
  text-align: center;
  opacity: 0.95;
}


/* --- Section cards by topic --- */
.section {
  width: 100%;
  max-width: 920px;
  margin: 0 0 1.5rem;
  padding: 1.25rem 1rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}


.section h2 {
  margin: 0 0 0.75rem;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

/* subtle, distinct tints that still fit the dark theme */
.section--arithmetic {
  background: #232729;
  border-color: #374246;
}

.section--algebra {
  background: #242327;
  /* slight magenta tint */
  border-color: #433b51;
}

.section--trig {
  background: #21282b;
  /* slight teal/blue tint */
  border-color: #38525a;
}

/* logic section: lighten a bit for contrast */
.section--logic {
  background: #2b2f33; /* lighter than others */
  border-color: #5a6a73; /* softer, cooler border */
}

/* make menus lay out nicely inside sections */
.section .menu {
  display: flex;
  flex-direction: column;
  /* stack children vertically */
  gap: 12px;
  /* keep spacing */
}

/* a touch more size/weight for links inside cards */
.section .menu a {
  font-size: 1.05rem;
  padding: 0.9rem 1rem;
  border-color: #8eadbb;
}
