/* Light card on a dark site */
#ants-apples-root {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #fdfaf5;
  color: #222;
  padding: 16px;
  max-width: 480px;
  margin: 0 auto;
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  position: relative;
  overflow: hidden;
  /* Background clipping */
}

.banner-container {
  margin: -16px -16px 16px -16px;
  /* Flush with top and sides */
  line-height: 0;
}

#ants-banner {
  width: 100%;
  height: auto;
  display: block;
}

#ants-apples-root header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  color: #222;
}

#ants-apples-root .header-left {
  display: flex;
  gap: 6px;
  align-items: center;
}

#ants-apples-root .status {
  font-size: 0.8rem;
  color: #666;
  text-align: center;
  line-height: 1.4;
  margin-top: 4px;
}

#ants-apples-root .status-line {
  white-space: nowrap;
}

#ants-grid-size-btn,
#ants-music-toggle,
#ants-print-worksheet,
#ants-dev-mode-btn {
  border: none;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.8rem;
  background: #ddd;
  color: #222;
  cursor: pointer;
}

#ants-music-toggle {
  background: #f0e4ff;
}

#ants-print-worksheet {
  background: #e0f5e5;
  color: #2e7d32;
  font-weight: 600;
}

#ants-dev-mode-btn {
  background: #e3f2fd;
  color: #1976d2;
  font-weight: 600;
}

#ants-dev-mode-btn.active {
  background: #1976d2;
  color: #fff;
}


#ants-grid-size-btn:active,
#ants-music-toggle:active,
#ants-print-worksheet:active,
#ants-dev-mode-btn:active {
  transform: scale(0.97);
}



#ants-apples-root main {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #222;
}

#ants-apples-grid {
  border-collapse: collapse;
  margin-top: 8px;
}

#ants-apples-grid td {
  width: 56px;
  height: 56px;
  border: 1px solid #444;
  text-align: center;
  vertical-align: middle;
  font-size: 1.3rem;
  user-select: none;
  color: #222;
  background: #ffffff;
}

#ants-apples-grid td.header {
  background: #ffe9a9;
  font-weight: 600;
  color: #222;
}

#ants-apples-grid td.tile {
  background: #ffffff;
  cursor: pointer;
}

#ants-apples-grid td.tile.inactive {
  cursor: default;
  background: #f5f5f5;
}

#ants-apples-grid td.tile.embargoed {
  cursor: not-allowed;
  background: #ececec;
  color: #bbb;
  font-weight: normal;
}

#ants-apples-grid td.tile.pending {
  background: #ffe66b;
}

#ants-apples-grid td.tile.correct {
  background: #9be7a0;
}

#ants-apples-grid td.tile.incorrect {
  background: #ff9b9b;
}

#ants-apples-root .controls {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  gap: 8px;
}

#ants-apples-root .btn {
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  background: #333;
  color: #fdfaf5;
  cursor: pointer;
}

#ants-apples-root .btn.secondary {
  background: #777;
  color: #fdfaf5;
}

#ants-apples-root .btn:active {
  transform: scale(0.97);
}

#ants-apples-root .message {
  margin-top: 8px;
  min-height: 20px;
  font-size: 0.9rem;
  color: #222;
  text-align: center;
}

/* Helper calculator */
#ants-helper {
  width: 100%;
  margin-top: 16px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff8e6;
  border: 1px solid #e5cf99;
  box-sizing: border-box;
}


#ants-helper-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: #333;
}

#ants-helper-inputs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}

.ants-helper-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.75rem;
  color: #333;
}

.ants-helper-label {
  margin-bottom: 2px;
}

#ants-helper-first,
#ants-helper-second {
  border-radius: 12px;
  padding: 4px 10px;
  font-size: 1.1rem;
  border: 1px solid #bbb;
  background: #f2f4f7;
  color: #222;
}

#ants-helper-op {
  font-size: 1.4rem;
  font-weight: 700;
  color: #222;
}

#ants-helper-visual {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
  font-size: 1.6rem;
}

#ants-helper-ants,
#ants-helper-apples {
  min-width: 40px;
  text-align: center;
}

#ants-helper-apples {
  line-height: 1.3;
}

#ants-helper-plus {
  font-size: 1.4rem;
  font-weight: 700;
  color: #222;
}

/* Keypad overlay */
#ants-apples-keypad-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: none;
  justify-content: center;
  align-items: flex-end;
  z-index: 9999;
}

#ants-apples-keypad {
  width: 100%;
  max-width: 480px;
  background: #ffffff;
  border-radius: 16px 16px 0 0;
  padding: 16px 16px 32px;
  /* more padding, esp. bottom */
  margin-bottom: 16px;
  /* lift away from OS footer */
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.4);
  color: #222;
}

#ants-apples-keypad-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 0.9rem;
  color: #222;
}

#ants-keypad-equation {
  font-weight: 700;
  font-size: 1.1rem;
}

#ants-apples-keypad-display {
  font-size: 1.4rem;
  font-weight: 600;
  text-align: right;
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  margin-bottom: 8px;
  min-height: 36px;
  background: #fdfaf5;
  color: #222;
}

#ants-apples-keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 6px;
}

#ants-apples-root .key {
  border-radius: 10px;
  padding: 8px 0;
  border: 1px solid #555;
  text-align: center;
  font-size: 1.1rem;
  cursor: pointer;
  user-select: none;
  background: #f5f5f5;
  color: #222;
}

#ants-apples-root .key:active {
  transform: scale(0.97);
  background: #e0e0e0;
}

#ants-apples-keypad-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 8px;
}

.key-side-by-side {
  display: flex;
  gap: 6px;
}

.key-side-by-side .key.action {
  flex: 1;
  min-width: 0;
  padding: 8px 0;
  font-size: 0.75rem;
}

#ants-apples-root .key.action {
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid #555;
  background: #f5f5f5;
  cursor: pointer;
}

#ants-apples-root .key.action[data-action="clear"] {
  background: #fde4e4;
  border-color: #c62828;
  color: #c62828;
}

#ants-apples-root .key.action[data-action="submit"] {
  background: #e0f5e5;
  border-color: #2e7d32;
  color: #2e7d32;
  font-weight: 700;
}

#ants-apples-root .key.action[data-action="zero"] {
  font-weight: 400;
  font-size: 1.1rem;
}

@media (min-width: 480px) {
  #ants-apples-grid td {
    width: 64px;
    height: 64px;
  }
}

/* Grid size + operation picker overlay */
#ants-size-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

#ants-size-dialog {
  background: #ffffff;
  border-radius: 16px;
  padding: 16px 18px 14px;
  max-width: 340px;
  width: 90%;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  color: #222;
}

#ants-size-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 8px;
}

#ants-size-body {
  font-size: 0.85rem;
  margin-bottom: 12px;
}

#ants-size-select {
  width: 100%;
  border-radius: 999px;
  border: 1px solid #bbb;
  padding: 6px 10px;
  font-size: 0.95rem;
  background: #f2f4f7;
  color: #222;
  margin-bottom: 10px;
}

#ants-level-count-label {
  font-size: 0.85rem;
  margin-bottom: 4px;
  margin-top: 4px;
}

#ants-level-count-input {
  width: 100%;
  border-radius: 999px;
  border: 1px solid #bbb;
  padding: 6px 10px;
  font-size: 0.95rem;
  background: #fdfdfd;
  color: #222;
  margin-bottom: 10px;
  box-sizing: border-box;
}

#ants-op-title {
  font-size: 0.85rem;
  margin-bottom: 4px;
}

#ants-op-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
  font-size: 0.85rem;
}

#ants-op-options label {
  display: flex;
  align-items: center;
  gap: 6px;
}

#ants-op-options input[type="radio"] {
  transform: scale(1.1);
}

#ants-size-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

#ants-size-start-btn,
#ants-size-cancel-btn {
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

#ants-size-start-btn {
  background: #333;
  color: #fdfaf5;
}

#ants-size-cancel-btn {
  background: #ddd;
  color: #222;
}

#ants-size-start-btn:active,
#ants-size-cancel-btn:active {
  transform: scale(0.97);
}

/* Win overlay */
#ants-win-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10001;
}

#ants-win-dialog {
  background: #ffffff;
  border-radius: 18px;
  padding: 18px 20px 16px;
  max-width: 340px;
  width: 90%;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  color: #222;
  text-align: center;
}

#ants-win-title {
  font-size: 1.05rem;
  font-weight: 800;
  margin-bottom: 8px;
}

#ants-win-body {
  font-size: 0.9rem;
  margin-bottom: 12px;
}

#ants-win-actions {
  display: flex;
  justify-content: center;
}

#ants-win-play-again {
  border: none;
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  background: #3b7c36;
  color: #fdfaf5;
  cursor: pointer;
}

#ants-win-play-again:active {
  transform: scale(0.97);
}

/* Master Mode Visuals */
.master-mode-badge {
  width: 100%;
  margin-top: 16px;
  padding: 12px;
  border-radius: 12px;
  background: linear-gradient(135deg, #ffd700 0%, #ffcc00 50%, #b8860b 100%);
  border: 2px solid #fff;
  box-shadow: 0 4px 15px rgba(184, 134, 11, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.5);
  color: #5c4306;
  text-align: center;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 0.9rem;
  animation: master-pulse 3s infinite ease-in-out;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-sizing: border-box;
}

.master-mode-badge::before,
.master-mode-badge::after {
  content: "★";
  font-size: 1.1rem;
}

@keyframes master-pulse {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }

  50% {
    transform: scale(1.02);
    filter: brightness(1.1);
    box-shadow: 0 6px 20px rgba(184, 134, 11, 0.6);
  }

  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

.master-victory-title {
  color: #b8860b !important;
  font-weight: 900 !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.master-victory-img {
  width: 160px;
  height: auto;
  margin: 15px auto 5px;
  display: block;
}

.ghost {
  opacity: 0.25;
  filter: grayscale(1);
}

/* Dev Mode styles */
#ants-dev-view {
  width: 100%;
  margin-top: 10px;
}

.dev-banner {
  background: #1976d2;
  color: #fff;
  padding: 8px;
  border-radius: 12px 12px 0 0;
  font-weight: 700;
  text-align: center;
  font-size: 0.9rem;
  letter-spacing: 1px;
}

#ants-dev-canvas {
  background: #fff;
  border: 2px dashed #1976d2;
  border-top: none;
  border-radius: 0 0 12px 12px;
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
}

.dev-placeholder {
  color: #999;
  font-style: italic;
  font-size: 0.9rem;
  text-align: center;
}
/* Fractions Dev Mode UI */
.fractions-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  width: 100%;
}

.fraction-problem {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  flex-wrap: wrap;
}

.fraction-vis {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 50px;
}

.f-box {
  height: 24px;
  border: 2px solid #333;
  background: #eee;
}

.f-math {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 1.5rem;
  font-weight: 700;
  min-width: 40px;
}

.f-bar {
  width: 100%;
  height: 3px;
  background: #333;
  margin: 4px 0;
}

.f-op {
  font-size: 2rem;
  font-weight: 800;
  color: #333;
  padding: 0 10px;
}

.f-res-input {
  width: 45px;
  height: 45px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  border: 2px solid #1976d2;
  border-radius: 8px;
  background: #fff;
  color: #1976d2;
}

.f-res-input:focus {
  outline: none;
  background: #e3f2fd;
}

.f-level-track {
  font-size: 0.9rem;
  font-weight: 600;
  color: #666;
  background: #fff8e6;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid #e5cf99;
}

.f-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
}

/* Fractions Dev Settings */
.f-settings {
  display: flex;
  gap: 12px;
  background: #f0f4f8;
  padding: 6px;
  border-radius: 999px;
  border: 1px solid #d1d9e6;
  margin-bottom: 20px;
}

.f-setting-btn {
  border: none;
  background: transparent;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.4rem;
  font-weight: 800;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.f-setting-btn.active {
  background: #1976d2;
  color: #fff;
  box-shadow: 0 2px 8px rgba(25, 118, 210, 0.4);
}

.f-setting-btn:hover:not(.active) {
  background: #e1e7ef;
}

/* Dev Picker UI */
.dev-picker-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}
.dev-picker-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: #1976d2;
  margin-bottom: 30px;
}

.dev-picker-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  width: 100%;
  max-width: 320px; /* Force compact 2x2 on most devices */
  justify-content: center;
}

.picker-card {
  width: auto;
  aspect-ratio: 1 / 1;
  background: #f8faff;
  border: 2px solid #e1e7ef;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  padding: 10px;
}

.picker-card:hover {
  transform: translateY(-5px);
  border-color: #1976d2;
  background: #fff;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05);
}

.picker-card .card-icon {
  font-size: 2.4rem;
  font-weight: 800;
  color: #1976d2;
}

.picker-card .card-text {
  font-size: 0.9rem;
  font-weight: 700;
  color: #444;
}

/* Common Home Button for Dev */
.f-home-btn {
  position: absolute;
  top: 8px;
  left: 8px;
  background: #fff;
  border: 1px solid #1976d2;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(25, 118, 210, 0.2);
  transition: all 0.2s;
  z-index: 99;
  pointer-events: auto;
}

.f-home-btn:hover {
  background: #f0f0f0;
  transform: scale(1.1);
}

.fractions-container {
  position: relative;
  padding-top: 20px;
}

/* Algebra Blank Canvas */
.algebra-dev-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.algebra-title {
  font-size: 1.6rem;
  color: #333;
  margin-bottom: 20px;
}

.algebra-canvas-blank {
  width: 100%;
  max-width: 500px;
  height: 200px;
  border: 4px dashed #ccc;
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #888;
  background: #fafafa;
}

.blank-indicator {
  font-family: monospace;
  font-size: 0.8rem;
  margin-bottom: 10px;
  color: #aaa;
}

/* Algebra Dev UI */
.algebra-problem-box {
  background: #fff;
  border: 1px solid #e1e7ef;
  border-radius: 24px;
  padding: 30px;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  margin-top: 10px;
}

.algebra-text {
  font-size: 2.2rem;
  font-weight: 800;
  color: #333;
  font-family: 'Courier New', Courier, monospace;
}

.algebra-input-row {
  display: flex;
  align-items: center;
  gap: 15px;
}

.x-label {
  font-size: 1.8rem;
  font-weight: 700;
  color: #1976d2;
}

.algebra-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: #666;
  margin-bottom: 20px;
}

/* Chains Dev Mode Styles */
.chains-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  position: relative;
  padding-top: 25px;
}

.c-len-btn {
  border: 1px solid #d1d9e6;
  background: white;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #666;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 45px;
}

.c-len-btn:hover {
  background: #f0f4f8;
}

.c-len-btn.active {
  background: #1976d2;
  color: white;
  border-color: #1976d2;
  box-shadow: 0 2px 8px rgba(25, 118, 210, 0.4);
}

.c-mode-btn {
  border: 1px solid #d1d9e6;
  background: white;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #666;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 90px;
}

.c-mode-btn.active {
  background: #6a1b9a;
  color: white;
  border-color: #6a1b9a;
}

.math-no-break {
  white-space: nowrap;
}

.chains-container .algebra-text {
  white-space: nowrap;
  font-size: 2.2rem;
  max-width: 100%;
  overflow-x: hidden;
  text-align: center;
}

.math-op-mul {
  font-weight: 900;
  font-size: 0.85em;
  vertical-align: middle;
  padding: 0 4px;
  display: inline-block;
  transform: translateY(-2px);
  color: #333;
}

.math-var {
  font-family: "Times New Roman", Times, serif;
  font-style: italic;
  font-weight: 800;
  color: #1976d2; /* Keeps it distinct from numbers */
}
