body {
  background: #222;
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, Arial, sans-serif;
  padding: 0px 24px;
  font-size: 1.05rem;
  background: #2c2447;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.2s;
  min-height: 100vh;
  box-sizing: border-box;
}

.page-header {
  color: #fff;
  font-size: 4rem;
  font-weight: bold;
  text-align: center;
  margin: 5px 0 0 0;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

/* Mathematical f styling */
.math-f {
  font-family: "Cambria Math", "Latin Modern Math", "STIX Two Math", "Times New Roman", serif;
  font-style: italic;
  font-weight: bold;
  color: white; /*#c03a3a;*/
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.6);
  position: relative;
  display: inline-block;
  font-size: 1.2em;
  margin-right: 0.3em;
}

.page-copyright {
  color: #fff;
  font-size: 0.95rem;
  text-align: center;
  opacity: 0.8;
  margin: 5px auto 10px auto;
  padding: 5px 15px;
  border-radius: 5px;
  background: rgba(44, 36, 71, 0.9);
  width: fit-content;
}
.quiz-form .start-btn:disabled {
  background: #ccc;
  color: #888;
  cursor: not-allowed;
}

.centered-container {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 10px;
  padding-bottom: 10px;
  box-sizing: border-box;
}
.quiz-panel {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 0 8px #8888;
  padding: 16px 32px 16px 32px;
  min-width: 340px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Start screen layout with side-by-side panels */
.start-screen-content {
  display: flex;
  gap: 40px;
  align-items: center;
  justify-content: center;
}

/* Promotion panel styles */
.promo-panel {
  background: #2c2447;
  border-radius: 18px;
  box-shadow: 0 0 8px #8888;
  padding: 24px 32px;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.promo-text {
  color: #fff;
  font-size: 1.2rem;
  font-weight: bold;
  margin: 0;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.promo-text-small {
  color: #fff;
  font-size: 1rem;
  margin: 2px 0 2px 0;
  opacity: 0.7;
}

.donate-btn {
  background: #2e5bba;
  color: white;
  border: none;
  padding: 12px 30px;
  margin:10px auto 50px auto;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.copy-link-btn {
  padding:0;
  margin:0;
  height:30px;
  width:30px;
  background: transparent;
  color: white;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}
.donate-btn:hover, .copy-link-btn:hover {
  background: #218838;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}
#copy-link-icon {
  height:30px;
  width:30px;
  border-radius: 4px;
}
.website-link {
  display: inline-block;
  transition: transform 0.2s;
}


.website-link:hover {
  transform: scale(1.05);
}

.website-logo {
  height: 60px;
  width: auto;
  margin:4px auto 40px auto;
  border-radius: 8px;
}

/* Responsive design for smaller screens */
@media (max-width: 800px) {
  .start-screen-content {
    flex-direction: column;
    align-items: center;
    gap: 20px;
  }
  
  .promo-panel {
    min-width: 240px;
  }
}

.quiz-title {
  font-size: 1.7rem;
  color: #b00;
  margin-bottom: 8px;
  font-weight: bold;
  text-align: center;
  letter-spacing: 1px;
}
.quiz-form {
  color:#777;
  background: #f8f8f8;
  border-radius: 18px;
  padding: 8px 12px 18px 0px;
  box-shadow: 0 0 6px #bbb8;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 420px;
}
.quiz-form label {
  color: #666;
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  cursor: pointer;
}
.quiz-form input[type="checkbox"] {
  margin-left:12px;
  margin-top:3px;
  margin-right: 18px;
  transform: scale(1.1);
  accent-color: #b00;
}

.quiz-form input[type="checkbox"]:disabled {
  opacity: 1;
  cursor: not-allowed;
}
.quiz-form input[type="number"] {
  width: 38px;
  font-size: 1rem;
  margin-left: 6px;
  padding: 2px 3px;
  border-radius: 4px;
  border: 1px solid #bbb;
  text-align: center;
  transition: all 0.3s ease;
}

.quiz-form input[type="number"]:disabled {
  background-color: #f5f5f5;
  color: #999;
  border-color: #ddd;
  cursor: not-allowed;
}

.quiz-form input[type="number"]:focus {
  outline: 2px solid #007bff;
  outline-offset: 1px;
  border-color: #007bff;
}
.button-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 32px;
  justify-content: center;
  align-items: center;
}

.mode-slider-container {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.mode-label {
  font-size: 1rem;
  color: #333;
  font-weight: normal;
  min-width: 80px;
  text-align: center;
}

.mode-slider {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 34px;
}

.mode-slider input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #007bff;
  transition: 0.3s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

input:checked + .slider:before {
  transform: translateX(26px);
}

.coefficient-slider-container {
  display: flex;
  justify-content: center;
  margin: 0;
  min-height: 32px;
}

.coefficient-slider-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.coefficient-label {
  font-size: 0.85rem;
  color: #666;
  font-weight: 500;
  min-width: 62px;
  text-align: center;
}

.coefficient-slider {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
}

.coefficient-slider input {
  opacity: 0;
  width: 0;
  height: 0;
}

.coefficient-slider-track {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #6c757d;
  transition: 0.3s;
  border-radius: 28px;
}

.coefficient-slider-track:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

input:checked + .coefficient-slider-track {
  background-color: #6c757d;
}

input:checked + .coefficient-slider-track:before {
  transform: translateX(22px);
}

.coefficient-slider-container.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.coefficient-slider input:disabled + .coefficient-slider-track {
  cursor: not-allowed;
  opacity: 0.4;
}

.coefficient-slider-container.disabled .coefficient-label {
  color: #ccc;
}

.quiz-form .start-btn {
  margin-top: 4px;
  padding: 8px 24px;
  font-size: 1.05rem;
  background: #2e5bba;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.2s;
  height: 44px;
  width: 160px;
}

.quiz-form .start-btn:hover {
  background: #1e4a9a;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}
.quiz-form .start-btn:disabled {
  background: #ccc;
  color: #888;
  cursor: not-allowed;
}
.copyright {
  margin-top: 16px;
  color: #444;
  font-size: 0.95rem;
  text-align: center;
  opacity: 0.8;
}

/* Quiz UI styles */
.quiz-graph-panel {
  display: flex;
  flex-direction: row;
  width: 900px;
  max-width: 98vw;
  min-height: 520px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 0 8px #8888;
  margin: 0 auto;
  position: relative; /* Add relative positioning for absolute child */
}

/* Red X quit button in top right corner */
.quit-btn-x {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  background: #c03a3a;
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 2rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: all 0.2s;
  line-height: 1;
  padding: 0;
  font-family: Arial, sans-serif;
  text-align: center;
}

.quit-btn-x:hover {
  background: #a02d2d;
  transform: scale(1.1);
}

.quit-btn-x:active {
  transform: scale(0.95);
}
.quiz-graph-left {
  flex: 7 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 32px 0 32px 0;
  border-right: 1.5px solid #eee;
  min-width: 0;
}
.quiz-graph-title {
  color:#777;
  font-size: 1.3rem;
  margin-bottom: 4px;
  margin-top: 0;
  text-align: left;
  font-weight: 500;
  width: 100%;
  max-width: 90vw;
  margin-left: 24px;
}
.quiz-graph-func {
  color: #b00;
  font-size: 1.5rem;
  font-weight: bold;
  margin-left: 8px;
  display: inline-block;
}

/* Piecewise function formatting */
.piecewise-container {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  vertical-align: middle;
}

.piecewise-brace {
  font-size: 3rem;
  line-height: 1;
  margin-right: 8px;
  margin-top: -20px;

  display: flex;
  align-items: center;
  height: 100%;
}

.piecewise-expressions {
  display: flex;
  flex-direction: column;
  margin-top:-10px;
}

.piecewise-piece {
  display: flex;
  align-items: center;
  font-size: 1.2rem;
  line-height: 1.2;
}

.piecewise-condition {
  margin-left: 12px;
  font-size: 1rem;
  font-weight: normal;
}

/* Smaller piecewise functions for results page */
.results-page .piecewise-container {
  margin-left: 4px;
}

.results-page .piecewise-brace {
  font-size: 1.5rem;
  margin-right: 4px;
  margin-top: -8px;
}

.results-page .piecewise-expressions {
  margin-top: -4px;
}

.results-page .piecewise-piece {
  font-size: 0.75rem;
  line-height: 1.1;
  font-weight: normal;
}

.results-page .piecewise-condition {
  margin-left: 6px;
  font-size: 0.65rem;
  font-weight: normal;
}

/* Larger sizing for view results screen (not print) */
@media screen {
  .results-page canvas {
    width: 1200px !important;
    height: 900px !important;
    max-width: 90vw;
    max-height: 60vh;
    object-fit: contain;
  }
  
  .results-page td {
    padding: 20px !important;
  }
  
  .results-page div[style*="font-size: 1.1rem"] {
    font-size: 1.6rem !important;
  }
  
  .results-page div[style*="font-weight: bold"][style*="margin-left: 15px"] {
    font-size: 1.4rem !important;
  }
}

/* Stacked fraction styling */
.fraction {
  display: inline-block;
  vertical-align: middle;
  text-align: center;
  position: relative;
  margin:auto 2px;
}

.fraction .numerator {
  display: block;
  border-bottom: 1px solid currentColor;
  padding-bottom: 1px;
  font-size: 0.9em;
  line-height: 1;
}

.fraction .denominator {
  display: block;
  padding-top: 1px;
  font-size: 0.9em;
  line-height: 1;
}
.quiz-graph-canvas-container {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 0 8px #bbb8;
  margin-top: 16px;
  margin-bottom: 4px;
  padding: 0;
  padding-top: 28px;
  position: relative;
  width: 98%;
  height: 510px;
  display: flex;
  /*align-items: center;
  */

  justify-content: center;
  overflow: hidden; /* Hide overflow to ensure masks work properly */
}
.quiz-graph-canvas-container canvas {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 0 4px #bbb8;
  width: 98%;
  height: 500px;
  display: block;
}
.quiz-graph-canvas-container::before {
  content: '';
  position: absolute;
  top: 28px;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 10;
  box-shadow: 
    inset 8px 0 0 #fff,       /* Left edge mask - smaller to avoid covering y-axis labels */
    inset -24px 0 0 #fff,     /* Right edge mask */
    inset 0 24px 0 #fff,      /* Top edge mask */
    inset 0 -24px 0 #fff;     /* Bottom edge mask */
  border-radius: 10px;
}
.quiz-graph-coords {
  position: absolute;
  top: 0px;
  right: 24px;
  color: #c5c4c4;
  font-size: 1.1rem;
  pointer-events: none;
  user-select: none;
}
.quiz-graph-right {
  flex: 3 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 32px 0 32px 0;
  min-width: 0;
}
.quiz-graph-problem-nav {
  display: flex;
  align-items: center;
  margin-top:12px;
  margin-bottom: 12px;
  font-size: 1.2rem;
  font-weight: 500;
  color: #222;
}
.quiz-graph-problem-nav .arrow-btn {
  background-color: transparent;
  color:#6b59a7;
  border: none;
  border-radius: 50%;
  width: 80px;
  height: 80px;
  font-size: 4rem;
  margin: 0 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.quiz-graph-problem-nav .arrow-btn:hover {
  transition: font-size .1s;
  font-size: 4.1em;
}

/* Note: Arrow buttons are never disabled with circular navigation */
.quiz-graph-problem-nav .arrow-btn:disabled {
  cursor: not-allowed;
}
.quiz-graph-tool-btn {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  background: #fff;
  border: 2px solid #eee;
  border-radius: 10px;
  margin-bottom: 12px;
  padding: 12px 18px;
  font-size: 1.15rem;
  color: #333;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, border 0.2s;
  width: 100px;
  height: 80px;
  box-sizing: border-box;
  background-repeat: no-repeat;
  background-position: center;  
  background-size: 60px 60px;
}
.quiz-graph-tool-btn:hover {
  border: 2px solid #bbbbbb;
  background-size: 72px 72px;
}

.quiz-graph-tool-btn.clear {
  margin-top: 24px;
  border: 2px solid #eee;
  background: #fff;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 48px 48px;
  width: 80px;
  height: 80px;
}
.quiz-graph-tool-btn.clear:hover {
  border: 2px solid #bbbbbb;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 60px 60px;
}
.quiz-graph-action-row {
  display: flex;
  justify-content: center; /* Center the single check button */
  margin-top: 70px;
  width: 100%;
  max-width: 240px;
}
.quiz-graph-action-row button {
  font-size: 1.2rem;
  font-weight: bold;
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  margin: 0 8px;
  cursor: pointer;
  transition: background 0.2s;
}
.quiz-graph-action-row .check-btn {
  background: #2e5bba;
  width: 140px;
  color: #fff;
  display: none; /* Hidden by default until curve is drawn */
  transition: all 0.2s;
}

.quiz-graph-action-row .check-btn:hover {
  background: #1e4a9a;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.quiz-graph-action-row .check-btn.show {
  display: block; /* Show when curve is drawn */
}

/* Inactive state for tool buttons */
.quiz-graph-tool-btn.inactive {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Piecewise tools grid layout */
.piecewise-tools-grid {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  width: 100%;
  justify-content: center;
}

.piecewise-column {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Smaller piecewise tool buttons */
.quiz-graph-tool-btn.piecewise-tool-small {
  width: 80px;
  height: 80px;
  padding: 8px;
  margin-bottom: 0;
  background-size: 48px 48px;
  font-size: 0.9rem;
}

.quiz-graph-tool-btn.piecewise-tool-small:hover {
  background-size: 56px 56px;
}
@media (max-width: 1000px) {
  .quiz-graph-panel {
    flex-direction: row;
    width: 98vw;
    padding: 8px;
  }
  
  .quiz-graph-left {
    width: 85%;
    padding: 16px 8px;
    border-right: 1.5px solid #eee;
    border-bottom: none;
  }
  
  .quiz-graph-right {
    width: 15%;
    padding: 16px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  
  .quiz-graph-right .quiz-graph-tool-btn {
    display: block;
    width: 80px;
    height: 70px;
    margin: 1px auto;
    padding: 2px 3px;
    background-size: 32px 32px;
  }
  
  .quiz-graph-problem-nav {
    flex-direction: column;
    align-items: center;
    margin:0px;
    padding-top:28px;
    padding-bottom:12px;
  }

  .quiz-graph-right .arrow-btn {
    margin: 0;
  }
  
  #problem-counter {
    order: 0;
    margin: 0;
  }
  
  #prev-problem {
    order: -1;
  }
  
  #next-problem {
    order: 1;
  }

  #check-btn {
    width:100px;
    margin:0px;
  }
}

@media (max-width: 500px) {
  .page-header {
    font-size: 3rem;
    margin: 5px 0 3px 0;
  }
  
  .quiz-graph-problem-nav {
    flex-direction: column;
    align-items: center;
    padding-top:60px;
  }

  .quiz-graph-right .arrow-btn {
    margin: 1px 0;
  }
  
  #problem-counter {
    order: 0;
    margin: 4px 0;
  }
  
  #prev-problem {
    order: -1;
  }
  
  #next-problem {
    order: 1;
  }

    
  .quiz-graph-right .quiz-graph-tool-btn {
    display: block;
    width: 60px;
    height: 50px;
    margin: 4px auto;
    padding: 2px 3px;
    background-size: 32px 32px;
  }

}

/* Print styles for chromebooks */
@media (max-height: 600px) {
    .page-header {
        font-size:1.4rem;
        margin:0;
        padding:0;
    }
    .centered-container {
      padding-top: 2px;
      padding-bottom: 2px;
    }
    .quiz-panel {
        padding: 6px 32px 6px 32px;
    }
    .quiz-title {
        font-size: 1.4rem;
        margin:0;
        padding:0;
    }
    .button-container {
        margin-top: 2px;
    }
    .math-f {
        font-size: 1.2em;
        margin-right: 0.1em;
    }
    .quiz-graph-func {
        margin-top: 18px;
    }
    .quiz-graph-left {
        margin:0;
        padding:0;
    }
    .quiz-graph-canvas-container {
        margin:0;
        padding:0;
        position:relative;
        top:0px;
        height: 500px;
    }
    .quiz-graph-canvas-container::before {
        top: 0px;
    }
    .quiz-graph-panel {
      height:520px;
      min-height: 500px;
      padding:0;
    }
    .quit-btn-x {
        top: 4px;
        font-size: 1.5rem;
        font-family: Arial, sans-serif;
        text-align: center;
    }
    .quiz-graph-problem-nav {
        margin-top:4px;
        margin-bottom: 4px;
    }
     
    .quiz-graph-right .quiz-graph-tool-btn {
        width: 70px;
        height: 60px;
        background-size: 44px 44px;
    }
    .quiz-graph-tool-btn:hover {
        background-size: 52px 52px;
    }
    .quiz-graph-tool-btn.clear:hover {
        background-size: 48px 48px;
    }
    #check-btn:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    }
}

/* Print styles for pagination */
@media print {
  body {
    background: white !important;
    color: black !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  
  /* Hide main UI and page elements during print */
  #main-ui, .page-header, .page-copyright {
    display: none !important;
  }
  
  /* Hide buttons during print */
  button {
    display: none !important;
  }
  
  /* Show name field only when printing */
  .print-only {
    display: block !important;
  }
  
  /* Show worksheet footer when printing */
  .print-only-footer {
    display: flex !important;
  }
  
  /* Force page size and margins */
  @page {
    size: letter;
    margin: 0.5in;
  }
}