.rg-math-surface {
  background: #ffffff;
  border: 2px solid #000;
  border-radius: 10px;
  padding: 14px;
  min-height: 520px;
  position: relative;
}

/* Match new metric ruler game page background (w3-pale-green) */
body {
  background-color: #ddffdd;
}

.rg-math-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  width: 100%;
}

.rg-math-header-main {
  display: flex;
  gap: 10px;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
}

.rg-math-header-label {
  flex: 0 0 auto;
  white-space: nowrap;
}

.rg-math-header-field {
  flex: 1 1 auto;
  min-width: 0; /* allow shrinking inside flex row */
}

.rg-math-header-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
  flex: 0 0 auto;
}

/* Single-column game layout */
.rg-math-game-col {
  position: relative;
  display: flex;
  flex-direction: column;
  max-width: 1100px;
  margin: 0 auto;
  padding: 15px 0;
}

.rg-math-game-col .canvas-area {
  position: relative;
  z-index: 1;
}

#buttonBar {
  position: relative;
  z-index: 2;
  width: 100%;
  margin: 0 auto;
  text-align: center;
  flex: 0 0 auto;
}

#btnStart,
#btnSettings,
#btnBackToBuilder {
  background-color: #339966;
  color: white;
  border: 0;
  border-radius: 5px;
  height: 40px;
  width: 220px;
  font-size: 24px;
  margin: 10px 20px 10px auto;
  cursor: pointer;
}

#btnSettings {
  float: none;
}

#btnBackToBuilder {
  /* font-size: 16px; */
  float: none;
  /* width: 170px; */
}

#btnStart:hover,
#btnSettings:hover,
#btnBackToBuilder:hover {
  background-color: #127041;
}

/* Thermometer-style submit button (same palette/hover as #btnStart) */
#btnSubmit {
  background-color: #339966;
  color: white;
  border: 0;
  border-radius: 5px;
  height: 40px;
  width: 210px;
  font-size: 24px;
  cursor: pointer;
}

#btnSubmit:hover {
  background-color: #127041;
}

/* Thermometer-style disabled submit button + spinner */
#btnSubmit:disabled {
  background-color: #cccccc !important;
  color: #666666 !important;
  cursor: not-allowed !important;
  opacity: 0.85;
}
#btnSubmit:disabled:hover {
  box-shadow: none !important;
}
.natspinner {
  width: 24px;
  height: 24px;
  border: 5px solid #000000;
  border-bottom-color: transparent;
  border-radius: 50%;
  display: inline-block;
  box-sizing: border-box;
  animation: rotation 1s linear infinite;
}
@keyframes rotation {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Results strip: match new-metric-ruler-game (assets/rulergame3betaCSS.css) */
#resultsBar {
  height: auto;
  min-height: 30px;
  margin: 5px auto;
  max-width: 800px;
}

.rg-math-results-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  gap: 12px 24px;
}

.rg-math-submit-col {
  flex: 0 0 auto;
}

.rg-math-display-board {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
}

#scoreColumn,
#questionColumn,
#timerColumn,
#levelColumn,
#strikesColumn {
  float: none;
  width: auto;
  min-width: 70px;
  text-align: center;
}

#scoreColumn {
  min-width: 100px;
}

#txtScore,
#txtQuestionNum {
  font-family: Consolas, "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", Monaco, "Courier New", monospace;
  font-size: 30px;
  font-weight: bold;
  height: 30px;
}

#questionColumn {
  min-width: 90px;
}

#timerColumn {
  width: 40px;
}

#timerCanvas {
  height: 34px;
  width: 30px;
}

#levelColumn {
  width: 80px;
}

#levelCanvas {
  height: 30px;
  width: 70px;
}

#strikesColumn {
  width: 100px;
}

#txtStrikes {
  height: 30px;
}

#txtStrikes img {
  height: 30px;
  width: 30px;
}

.resultsBarLabel {
  font-size: 9px;
  margin-top: 4px;
}

#timerColumn .resultsBarLabel {
  margin-top: -6px;
}
#levelColumn .resultsBarLabel {
  margin-top: -4px;
}

#strikesColumn .resultsBarLabel {
  margin-top: 0;
}

#questionBar {
  position: relative;
  z-index: 2;
  width: 100%;
  line-height: 1.2;
  text-align: center;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 7px;
}

.rg-math-mode-builder #questionBar {
  min-height: 10px;
}

/* .rg-math-mode-builder #questionBar:has(#txtQuestion.rg-math-builder-error) {
  min-height: 30px;
} */

.rg-math-mode-play #questionBar {
  min-height: 75px;
}

#txtQuestion {
  width: 100%;
  text-align: center;
}

.rg-math-mode-builder #txtQuestion.rg-math-builder-error {
  color: #f44336;
  font-size: 14px;
  font-weight: bold;
  line-height: 1.3;
  /* margin-top: -7px; */
}

/* Match new metric ruler game question styles */
#txtQuestion .questionInstruction{
  font-size: 20px;
  font-weight: bold;
  color: #000000;
}
#txtQuestion .questionMeasurement{
  font-size: 40px;
  font-weight: bold;
  color: #000000;
}
#txtQuestion .questionWrongInstruction{
  font-size: 20px;
  font-weight: bold;
  color: #f44336;
}
#txtQuestion .questionWrongMeasurement{
  font-size: 40px;
  font-weight: bold;
  color: #f44336;
}
#txtQuestion .questionFinalScore{
  font-size: 40px;
  font-weight: bold;
  color: #339966;
}

#txtQuestion .gameOver{
  font-size: 35px;
  font-weight: bold;
  color: #f44336;
}

#txtQuestion .rg-game-over-flash {
  display: inline-block;
  animation: rg-game-over-flash 0.55s ease-in-out infinite;
}

@keyframes rg-game-over-flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.rg-math-code {
  border: 1px solid #cfcfcf;
  border-bottom: 2px solid #1f8251;
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
  box-sizing: border-box;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 13px;
}

.rg-math-dropzone-wrap,
.rg-math-palette-wrap {
  margin-top: 14px;
}

.rg-math-builder-settings-wrap {
  margin-top: 14px;
}

.rg-math-dropzone-title,
.rg-math-palette-title,
.rg-math-builder-settings-title {
  margin-bottom: 8px;
}

.rg-math-dropzone {
  min-height: 70px;
  border: 2px dashed #2e9662;
  border-radius: 10px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  background: #f7fff8;
}

.rg-math-palette {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 10px;
  background: #f3fff6;
  border: 1px solid #d8f0df;
  border-radius: 10px;
}

.rg-math-builder-settings {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 10px;
  background: #f3fff6;
  border: 1px solid #d8f0df;
  border-radius: 10px;
}

.rg-math-setting-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
}

.rg-math-setting-row.rg-math-setting-row-clickable {
  cursor: pointer;
}

.rg-math-setting-row.rg-math-setting-row-clickable .rg-math-setting-label {
  cursor: pointer;
}

.rg-math-setting-row input[type="checkbox"] {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  accent-color: #1f8251;
  cursor: pointer;
  transform: translateY(1px);
}

.rg-math-setting-row input[type="checkbox"]:hover {
  filter: brightness(1.05);
}

.rg-math-setting-row input[type="checkbox"]:focus-visible {
  outline: 3px solid rgba(31, 130, 81, 0.35);
  outline-offset: 2px;
  border-radius: 4px;
}

.rg-math-setting-row input[type="checkbox"]:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  filter: grayscale(40%);
}

.rg-math-setting-label {
  font-weight: 700;
  margin-left: 5px;
}

.rg-math-setting-desc {
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.2;
  color: rgba(0, 0, 0, 0.72);
  font-weight: 400;
  margin-left: 5px;
}

.rg-math-setting-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.rg-math-setting-inline input[type="number"] {
  width: 90px;
}

.rg-tooltip {
  position: fixed;
  z-index: 9999;
  display: none;
  max-width: min(320px, calc(100vw - 16px));
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(11, 106, 63, 0.25);
  background: #ffffff;
  color: #1b1b1b;
  font-size: 13px;
  line-height: 1.2;
  box-shadow: 0 4px 14px rgba(0,0,0,0.10);
  pointer-events: none;
}
.rg-tooltip.rg-tooltip-visible {
  display: block;
}

.rg-math-palette-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.rg-math-palette-row + .rg-math-palette-row {
  padding-top: 12px;
  border-top: 1px dashed rgba(11, 106, 63, 0.25);
}

.rg-math-block {
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  width: 45px;
  height: 45px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 2px solid #0b6a3f;
  background: #2ecc71;
  color: #083a22;
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 2px 0 rgba(0,0,0,0.12);
}

.rg-math-block[data-kind="op"] { background: #7fe7a8; }

.rg-math-block.rg-math-block-rand-op {
  position: relative;
  padding: 0;
  overflow: hidden;
}

.rg-math-block.rg-math-block-rand-op-2::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 62%;
  height: 2px;
  background: #0b6a3f;
  transform: translate(-50%, -50%) rotate(-45deg);
  pointer-events: none;
  border-radius: 1px;
}

.rg-math-rand-op-sym {
  position: absolute;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  color: #083a22;
}

.rg-math-rand-op-tl { top: 5px; left: 5px; }
.rg-math-rand-op-tr { top: 5px; right: 5px; }
.rg-math-rand-op-bl { bottom: 5px; left: 5px; }
.rg-math-rand-op-br { bottom: 5px; right: 5px; }

.rg-math-block.rg-math-block-tape-ruler {
  flex-direction: column;
  /* width: 52px; */
  /* height: 52px; */
  padding: 5px 3px 4px;
  gap: 1px;
  background: #3aada0;
  border-color: #1d6b63;
  color: #083a22;
  font-weight: 700;
  line-height: 1.05;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.14);
}

/* .rg-math-block.rg-math-block-tape-ruler:hover,
.rg-math-block.rg-math-block-tape-ruler:focus-visible {
  background: #247a70;
  border-color: #145a52;
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.55),
    0 0 14px rgba(255, 255, 255, 0.32);
} */

.rg-math-tape-ruler-frac {
  display: block;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}

.rg-math-block-tape-ruler-compact .rg-math-tape-ruler-frac {
  font-size: 11px;
}

.rg-math-tape-ruler-label {
  display: block;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  opacity: 0.98;
}

.rg-math-block[data-kind="num"] { background: #66d990; }
.rg-math-block[data-kind="special"] { background: #33d17a; }
.rg-math-block.rg-math-block-disabled {
  opacity: 0.35;
  filter: grayscale(60%);
  pointer-events: none;
}

.rg-drop-slot {
  width: 10px;
  height: 45px;
  border-radius: 10px;
  border: 1px dashed rgba(11,106,63,0.45);
  background: rgba(46, 150, 98, 0.10);
}
.rg-drop-slot.rg-drop-slot-active {
  width: 22px;
  background: rgba(31, 130, 81, 0.16);
  border-color: rgba(31, 130, 81, 0.8);
}

.rg-math-placed-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.rg-math-placed-col.rg-fraction-merge-hint {
  outline: 3px solid rgba(31, 130, 81, 0.5);
  outline-offset: 4px;
  border-radius: 12px;
}

.rg-math-fraction-wrap.rg-fraction-digit-hint {
  outline: 3px solid rgba(31, 130, 81, 0.35);
  outline-offset: 4px;
}
.rg-math-fraction-wrap.rg-fraction-digit-hint-num .rg-math-block[data-fraction-part="num"] {
  box-shadow: 0 0 0 3px rgba(31, 130, 81, 0.45);
}
.rg-math-fraction-wrap.rg-fraction-digit-hint-den .rg-math-block[data-fraction-part="den"] {
  box-shadow: 0 0 0 3px rgba(31, 130, 81, 0.45);
}

.rg-math-fraction-slot {
  width: 52px;
  min-height: 28px;
  height: 28px;
  border-radius: 8px;
  border: 2px dashed rgba(11, 106, 63, 0.55);
  background: rgba(46, 150, 98, 0.18);
  box-sizing: border-box;
  flex-shrink: 0;
  position: relative;
}

/* Hint label — keeps target obvious without needing pixel-perfect aim */
.rg-math-fraction-slot::after {
  content: "÷";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  text-align: center;
  font-size: 14px;
  font-weight: 800;
  color: rgba(11, 106, 63, 0.45);
  pointer-events: none;
  line-height: 1;
}

.rg-math-fraction-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 6px 4px 6px;
  border-radius: 10px;
  border: 2px solid #0b6a3f;
  background: #eafcf0;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.1);
}

.rg-math-block-fraction-line {
  width: 48px;
  min-height: 36px;
  height: auto;
  font-size: 16px;
  padding: 4px 2px;
}

.rg-math-fraction-bar {
  width: 44px;
  height: 2px;
  background: #083a22;
  border-radius: 1px;
}

.rg-math-fraction-rotate {
  position: absolute;
  top: 0px;
  right: 0px;
  width: 20px;
  height: 20px;
  padding: 0;
  margin: 0;
  border: 1px solid rgba(11, 106, 63, 0.5);
  border-radius: 6px;
  background: #1a1a1a;
  color: #dff6e8;
  line-height: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rg-math-fraction-rotate-icon {
  display: block;
  flex-shrink: 0;
}

.rg-math-fraction-rotate:hover {
  background: #2a2a2a;
}

.rg-math-fraction-rotate:focus-visible {
  outline: 3px solid rgba(31, 130, 81, 0.45);
  outline-offset: 2px;
}

.rg-math-hint {
  margin-top: 8px;
  color: #2d2d2d;
  font-size: 13px;
}

.rg-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 5px;
  border: 1px solid #454545;
  background: #7fe7a8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.rg-pill-gameset {
  display: inline-block;
  padding: 2px 8px;
  margin: 2px;
  border-radius: 5px;
  border: 1px solid #ccc;
  background: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.rg-pill-white {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 5px;
  border: 1px solid #454545;
  background: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.rg-btn {
  background-color: #1f8251;
  color: white;
  border: 0;
  border-radius: 8px;
  height: 40px;
  padding: 0 14px;
  font-size: 16px;
  cursor: pointer;
}
.rg-btn:hover { background-color: #137b47; }
.rg-btn:active { transform: translateY(1px); }

.rg-btn-secondary {
  background-color: #0a85bd;
}
.rg-btn-secondary:hover { background-color: #0872a1; }

.rg-btn-primary {
  background-color: #1f8251;
}

.rg-math-play {
  margin-top: 12px;
}

.typecanvs-area {
  text-align: center;
  box-sizing: border-box;
}

#typeCanvas {
  display: block;
  max-width: 425px;
  width: 100%;
  height: auto;
  margin: 0 auto;
}

@media (orientation: portrait) and (max-width: 480px) {
  .typecanvs-area {
    padding: 0 6px;
    max-width: 100%;
  }

  #typeCanvas {
    max-width: 100%;
  }
}

.rg-math-answer-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  border: 2px solid #0b6a3f;
  background: rgba(235, 251, 241, 0.95);
  color: #083a22;
  font-weight: 900;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.12);
  vertical-align: middle;
  transform: translateY(-1px);
  margin-top: -8px;
}

.rg-math-answer-slot[data-has-value="0"] {
  margin-top: -8px;
  background: rgba(235, 251, 241, 0.65);
  color: rgba(8, 58, 34, 0.55);
}

.rg-math-results {
  margin-top: 12px;
}

.rg-math-play-settings {
  margin: 30px auto 20px auto;
  max-width: 520px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(11, 106, 63, 0.20);
  background: rgba(255, 255, 255, 0.9);
  font-size: 12px;
  line-height: 1.2;
  color: rgba(0,0,0,0.75);
}

.rg-math-play-settings .rg-pill {
  margin-right: 6px;
  margin-bottom: 6px;
  display: inline-block;
}

.rg-math-game-col #strikeBoard,
.rg-math-game-col #cheerBoard {
  position: absolute;
  left: 0;
  right: 0;
  top: 200px;
  z-index: 1000;
  text-align: center;
  pointer-events: none;
}

.setting-section {
  height: 110px;
  width: 100%;
  align-items: center;
  justify-content: center;
  position: relative;
}

#preferencesBox {
  width: 315px;
  margin: auto;
  margin-top: 10px;
  overflow: auto;
  display: none;
  z-index: 5;
  position: absolute;
  left: 50%;
  -webkit-transform: translateX(-50%);
  transform: translateX(-50%);
}

#preferencesBox h5 {
  text-align: left;
}

#cheerBoard {
  display: none;
}

.cheer{
  position: relative;
  width: 100%;
  height: 60px;
  max-height: 60px;
  padding-top: 15px;
  font-size: 30px;
  color: purple;
}

#strikeBoard img {
  width: 160px;
  max-width: 55vw;
  height: auto;
}

#timerBox, #soundsBox, #modeSelection {
  height: 45px;
}

/* Settings dropdowns (Mode, Timer, Rounding, Answer format, # of Questions) */
#builderSettings select {
  background: #fff;
  border: 2px solid #ccc;
  border-radius: 8px;
  padding: 6px 10px;
  font-weight: 600;
  color: #083a22;
}
#builderSettings select:hover {
  border-color: #094f2f;
}
#builderSettings select:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(11,106,63,0.25);
}

/* Tolerance number input */
#builderSettings input[type="number"] {
  background: #fff;
  border: 2px solid #ccc;
  border-radius: 8px;
  padding: 6px 10px;
  font-weight: 600;
  color: #083a22;
  width: 90px;
}
#builderSettings input[type="number"]:hover {
  border-color: #094f2f;
}
#builderSettings input[type="number"]:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(11,106,63,0.25);
}

@media (max-width: 680px) {
  .rg-math-header {
    flex-direction: column;
    align-items: stretch;
  }

  .rg-math-header-actions {
    justify-content: flex-start;
  }

  .rg-math-header-label {
    white-space: normal;
  }
}

