@font-face {
  font-family: 'Andika';
  src: url('assets/fonts/Andika-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Andika';
  src: url('assets/fonts/Andika-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-main: 'Andika', 'Century Gothic', 'Trebuchet MS', sans-serif;

  /* Classroom tabletop & ink tokens */
  --ink-strong: #1e232b;
  --ink-mid: #434b57;
  --ink-muted: #687280;
  --line-board: #2a303a;
  --line-soft: #cfd5df;
  --paper-white: #ffffff;
  --board-white: #fcfcfd;
  --carry-tint: #f8f5ee;
  --accent-ink: #1d4e89;
  --accent-ink-hover: #163d6d;
  --exchange-amber: #b86b11;

  /* Dynamic counter sizing (updated via data-cols on board) */
  --counter-size: 62px;
  --counter-font: 21px;
  --bowl-size: 96px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-main);
  color: var(--ink-strong);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* Soft overhead dove-grey woven linen classroom tabletop */
body {
  background-color: #e4e7ed;
  background-image:
    radial-gradient(ellipse at 22% 14%, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0) 58%),
    radial-gradient(ellipse at 85% 90%, rgba(160, 170, 186, 0.28) 0%, rgba(160, 170, 186, 0) 55%),
    repeating-linear-gradient(0deg, rgba(60, 68, 82, 0.028) 0px, rgba(60, 68, 82, 0.028) 1px, transparent 1px, transparent 4px),
    repeating-linear-gradient(90deg, rgba(60, 68, 82, 0.025) 0px, rgba(60, 68, 82, 0.025) 1px, transparent 1px, transparent 4px);
}

.app-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  width: 100%;
  height: 100dvh;
  padding: 12px 18px 16px;
  gap: 12px;
}

/* ============================================================
   TOP CLASSROOM UTILITY BAR (Clean cardstock, zero pill boxes)
   ============================================================ */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  z-index: 20;
}

.level-switcher {
  display: inline-flex;
  align-items: stretch;
  background: var(--paper-white);
  border: 1.5px solid var(--line-board);
  border-radius: 6px;
  box-shadow: 0 2px 0 rgba(30, 35, 43, 0.14);
  overflow: hidden;
}

.level-switcher .tool-btn {
  border: none;
  border-radius: 0;
  box-shadow: none;
  min-width: 42px;
  background: transparent;
}

.level-switcher .tool-btn:hover {
  background: #f1f3f7;
}

.level-readout {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 152px;
  padding: 4px 12px;
  border: none;
  border-left: 1px solid var(--line-soft);
  border-right: 1px solid var(--line-soft);
  background: var(--paper-white);
  font-family: var(--font-main);
  color: var(--ink-strong);
  cursor: pointer;
  line-height: 1.15;
  transition: background-color 140ms ease;
}

.level-readout:hover {
  background: #f5f7fa;
}

.level-short {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--ink-strong);
}

.level-name {
  font-size: 12px;
  font-weight: 400;
  color: var(--ink-muted);
}

/* Calculation paper strip (inspired by Miss Bates's sum card) */
.equation-card {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--paper-white);
  border: 1.5px solid var(--line-board);
  border-radius: 6px;
  padding: 5px 14px;
  box-shadow: 0 2px 0 rgba(30, 35, 43, 0.14);
  font-variant-numeric: tabular-nums;
}

.eq-num-btn {
  font-family: var(--font-main);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--ink-strong);
  background: transparent;
  border: 1.5px dashed transparent;
  border-radius: 4px;
  padding: 2px 7px;
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease, transform 120ms ease;
}

.eq-num-btn:hover {
  border-color: #9ba5b5;
  background: #f5f7fa;
}

.eq-num-btn:active {
  transform: scale(0.97);
}

.eq-op {
  font-size: 26px;
  font-weight: 700;
  color: var(--ink-mid);
  line-height: 1;
}

.eq-answer-box {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 78px;
  height: 44px;
  padding: 0 12px;
  border: 2px solid var(--line-board);
  border-radius: 4px;
  background: #f6f7fa;
  font-size: 28px;
  font-weight: 700;
  color: var(--ink-muted);
  transition: background-color 220ms ease, color 220ms ease, border-color 220ms ease, transform 240ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.eq-answer-box.revealed {
  background: #fff9e6;
  border-color: #b57b14;
  color: var(--ink-strong);
  transform: scale(1.04);
}

.reveal-sparkle {
  position: absolute;
  top: -12px;
  right: -14px;
  width: 28px;
  height: 28px;
  object-fit: contain;
  opacity: 0;
  transform: scale(0.3) rotate(-25deg);
  pointer-events: none;
  transition: opacity 220ms ease, transform 360ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.eq-answer-box.revealed .reveal-sparkle {
  opacity: 1;
  transform: scale(1) rotate(8deg);
}

/* Utility action buttons */
.action-bar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 6px 13px;
  background: var(--paper-white);
  border: 1.5px solid var(--line-board);
  border-radius: 6px;
  box-shadow: 0 2px 0 rgba(30, 35, 43, 0.15);
  font-family: var(--font-main);
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-strong);
  cursor: pointer;
  transition: transform 110ms ease, box-shadow 110ms ease, background-color 140ms ease;
}

.tool-btn:hover:not(:disabled) {
  background: #f4f6fa;
  transform: translateY(-1px);
  box-shadow: 0 3px 0 rgba(30, 35, 43, 0.16);
}

.tool-btn:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 1px 0 rgba(30, 35, 43, 0.15);
}

.tool-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  box-shadow: none;
}

.tool-btn:focus-visible,
.eq-num-btn:focus-visible,
.level-readout:focus-visible,
.bowl-btn:focus-visible,
.expand-col-btn:focus-visible,
.sweep-btn:focus-visible {
  outline: 3px solid var(--accent-ink);
  outline-offset: 2px;
}

.tool-btn.icon-only {
  padding: 6px 10px;
  min-width: 44px;
}

.tool-btn.primary-action {
  background: var(--accent-ink);
  border-color: #13355e;
  color: #ffffff;
  box-shadow: 0 2px 0 rgba(19, 53, 94, 0.35);
}

.tool-btn.primary-action:hover:not(:disabled) {
  background: var(--accent-ink-hover);
  box-shadow: 0 3px 0 rgba(19, 53, 94, 0.38);
}

.tool-btn.primary-action[aria-pressed="true"] {
  background: #8f5c0d;
  border-color: #5e3b05;
}

.btn-sprite {
  width: 26px;
  height: 26px;
  object-fit: contain;
  display: block;
  transition: transform 180ms cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.tool-btn:hover:not(:disabled) .btn-sprite {
  transform: scale(1.12) rotate(-6deg);
}

.tool-btn:active:not(:disabled) .btn-sprite {
  transform: scale(0.92);
}

/* ============================================================
   MAIN TABLETOP STAGE
   ============================================================ */
.desk-stage {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 20px;
  min-height: 0;
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
}

/* Left Rail: Ceramic Supply Bowls */
.bowls-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex: 0 0 auto;
  padding: 6px 4px;
  min-width: 112px;
  transition: background-color 180ms ease;
}

.bowls-rail.drop-return {
  background: rgba(217, 56, 58, 0.08);
  outline: 2px dashed #9d3234;
  border-radius: 10px;
}

.bowl-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: transparent;
  border: none;
  padding: 4px;
  cursor: grab;
  touch-action: none;
  font-family: var(--font-main);
  color: var(--ink-strong);
  transition: transform 180ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.bowl-btn:hover {
  transform: scale(1.07);
}

.bowl-btn:active {
  cursor: grabbing;
  transform: scale(0.95);
}

.bowl-btn.bowl-pop {
  animation: bowlBounce 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes bowlBounce {
  0% { transform: scale(1); }
  35% { transform: scale(0.9) rotate(-3deg); }
  70% { transform: scale(1.09) rotate(2deg); }
  100% { transform: scale(1); }
}

.bowl-img {
  width: var(--bowl-size);
  height: var(--bowl-size);
  object-fit: contain;
  filter: drop-shadow(0 6px 8px rgba(30, 35, 43, 0.22));
  pointer-events: none;
  display: block;
}

.bowl-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-strong);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.75);
}

/* ============================================================
   WOODEN-FRAMED PLACE VALUE WHITEBOARD
   ============================================================ */
.board-stage {
  flex: 1 1 auto;
  display: flex;
  align-items: stretch;
  justify-content: center;
  min-width: 0;
  min-height: 0;
}

.wood-frame {
  position: relative;
  width: 100%;
  max-width: 1080px;
  height: 100%;
  padding: 18px;
  border-radius: 6px;
  background-color: #c89452;
  background-image: url('assets/wood-frame.jpg');
  background-size: 360px 360px;
  box-shadow:
    0 14px 30px rgba(26, 30, 38, 0.22),
    0 4px 10px rgba(26, 30, 38, 0.14),
    inset 0 2px 2px rgba(255, 240, 210, 0.55),
    inset 0 -3px 5px rgba(84, 52, 16, 0.38);
  border: 1.5px solid #8a5c28;
  display: flex;
}

.expand-col-btn {
  position: absolute;
  left: -13px;
  top: 24px;
  width: 28px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper-white);
  border: 1.5px solid var(--line-board);
  border-radius: 4px;
  box-shadow: 0 2px 0 rgba(30, 35, 43, 0.22);
  font-family: var(--font-main);
  font-size: 19px;
  font-weight: 700;
  color: var(--ink-strong);
  cursor: pointer;
  z-index: 12;
  transition: transform 140ms ease, background-color 140ms ease;
}

.expand-col-btn:hover {
  background: #f2f5fa;
  transform: scale(1.08);
}

/* Quiet '+' marker sitting on the left wood frame aligned with Row 2 */
.board-plus-mark {
  position: absolute;
  left: 2px;
  top: 49%;
  width: 14px;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  color: #3a2308;
  text-shadow: 0 1px 0 rgba(255, 240, 210, 0.65);
  pointer-events: none;
  line-height: 1;
}

.whiteboard-surface {
  width: 100%;
  height: 100%;
  background: var(--board-white);
  border: 2px solid #754d1e;
  box-shadow: inset 0 2px 6px rgba(20, 25, 34, 0.14);
  display: grid;
  /* grid-template-columns set dynamically via JS */
  grid-template-rows: auto 13% 23% 23% 1fr;
  overflow: hidden;
}

/* Column responsiveness for counter sizes */
.whiteboard-surface[data-cols="2"] {
  --counter-size: 66px;
  --counter-font: 23px;
}

.whiteboard-surface[data-cols="3"] {
  --counter-size: 60px;
  --counter-font: 20px;
}

.whiteboard-surface[data-cols="4"] {
  --counter-size: 54px;
  --counter-font: 18px;
}

.whiteboard-surface[data-cols="5"] {
  --counter-size: 52px;
  --counter-font: 16px;
}

.whiteboard-surface[data-cols="6"] {
  --counter-size: 46px;
  --counter-font: 14px;
}

/* Column Header Cells */
.pv-header {
  position: relative;
  container-type: inline-size;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 6px;
  border-bottom: 2px solid var(--line-board);
  border-right: 2px solid var(--line-board);
  background: #ffffff;
  text-align: center;
  min-width: 0;
  overflow: hidden;
}

.pv-header:last-of-type,
.pv-cell.last-col {
  border-right: none;
}

.pv-header-title {
  font-size: clamp(13px, 1.7vw, 22px);
  font-weight: 700;
  color: var(--ink-strong);
  line-height: 1.1;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pv-header-short {
  display: none;
  font-size: clamp(14px, 2vw, 19px);
  font-weight: 700;
  color: var(--ink-strong);
  line-height: 1.1;
}

/* Automatically switch to crisp short labels (H, T, O, Th, TTh) when a column gets narrow on iPad */
@container (max-width: 145px) {
  .pv-header-title {
    display: none;
  }
  .pv-header-short {
    display: inline;
  }
}

/* Subtle column sweep down button — sits cleanly inline so it NEVER overlaps header text */
.sweep-btn {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #dde2eb;
  border-radius: 4px;
  background: #f7f9fc;
  color: var(--ink-mid);
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 150ms ease, background-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.pv-header:hover .sweep-btn,
.sweep-btn:focus-visible {
  opacity: 1;
}

.sweep-btn:hover {
  background: #edf1f7;
  border-color: var(--line-soft);
  color: var(--ink-strong);
  transform: scale(1.08);
}

.sweep-btn:active {
  transform: translateY(1px) scale(0.95);
}

/* Grid Cells (Carry Strip, Row 1, Row 2, Total Zone) */
.pv-cell {
  position: relative;
  border-right: 2px solid var(--line-board);
  border-bottom: 1.5px solid #48505e;
  padding: 5px;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  align-items: center;
  gap: 4px;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  transition: background-color 140ms ease;
  --tok-size: 56px;
}

.pv-cell.zone-carry {
  background: var(--carry-tint);
  border-bottom: 2px solid var(--line-board);
  padding: 3px 5px;
  gap: 4px;
}

.pv-cell.zone-row1 {
  background: var(--board-white);
}

.pv-cell.zone-row2 {
  background: var(--board-white);
  border-bottom: 3.5px solid var(--line-board);
}

.pv-cell.zone-total {
  background: #ffffff;
  border-bottom: none;
  align-content: center;
  padding: 6px 5px 46px;
  gap: 4px;
}

.pv-cell.drag-over {
  background: #eaf2ff;
  box-shadow: inset 0 0 0 2.5px #2f80ed;
}

/* Inner grid wrapper sized mathematically by ResizeObserver so counters NEVER overflow */
.cell-pack {
  display: grid;
  place-items: center;
  gap: var(--pack-gap, 4px);
  max-width: 100%;
  max-height: 100%;
}

/* ============================================================
   TACTILE GENERATED COUNTER TOKENS
   ============================================================ */
.counter-token {
  position: relative;
  width: var(--tok-size, var(--counter-size));
  height: var(--tok-size, var(--counter-size));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  touch-action: none;
  flex: 0 0 auto;
  transform: rotate(var(--tilt, 0deg));
  transition: transform 180ms cubic-bezier(0.34, 1.56, 0.64, 1), filter 160ms ease;
  filter: drop-shadow(0 3px 3px rgba(24, 28, 36, 0.22));
  z-index: 2;
}

.counter-token:hover {
  transform: scale(1.1) rotate(0deg);
  filter: drop-shadow(0 6px 8px rgba(24, 28, 36, 0.28));
  z-index: 8;
}

.counter-token:active {
  cursor: grabbing;
}

.counter-token.is-dragging {
  opacity: 0.18;
  transform: scale(0.92);
}

.counter-token.spawn-pop {
  animation: tokenPop 320ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes tokenPop {
  0% { transform: scale(0.35) rotate(var(--tilt, 0deg)); opacity: 0; }
  65% { transform: scale(1.12) rotate(var(--tilt, 0deg)); opacity: 1; }
  100% { transform: scale(1) rotate(var(--tilt, 0deg)); opacity: 1; }
}

.counter-token.exchanging-pulse {
  filter: drop-shadow(0 0 10px rgba(245, 195, 59, 0.95));
  z-index: 20;
}

.counter-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  display: block;
}

.counter-value {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-main);
  font-size: calc(var(--tok-size, var(--counter-size)) * 0.36);
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  letter-spacing: -0.02em;
}

/* High-contrast ink paired per generated counter disc */
.counter-token[data-place="0"] .counter-value {
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(90, 10, 12, 0.65);
}

.counter-token[data-place="1"] .counter-value {
  color: #241703;
  text-shadow: 0 1px 0 rgba(255, 240, 175, 0.55);
}

.counter-token[data-place="2"] .counter-value {
  color: #0b2418;
  text-shadow: 0 1px 0 rgba(190, 255, 224, 0.5);
}

.counter-token[data-place="3"] .counter-value {
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(10, 38, 86, 0.65);
}

.counter-token[data-place="4"] .counter-value {
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(48, 16, 86, 0.65);
}

.counter-token[data-place="5"] .counter-value {
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(6, 52, 58, 0.65);
}

/* Proportional font scaling for wider multi-digit labels */
.counter-token[data-place="2"] .counter-value {
  font-size: calc(var(--tok-size, var(--counter-size)) * 0.31);
}

.counter-token[data-place="3"] .counter-value {
  font-size: calc(var(--tok-size, var(--counter-size)) * 0.25);
}

.counter-token[data-place="4"] .counter-value {
  font-size: calc(var(--tok-size, var(--counter-size)) * 0.21);
}

.counter-token[data-place="5"] .counter-value {
  font-size: calc(var(--tok-size, var(--counter-size)) * 0.18);
}

/* ============================================================
   EXCHANGE 10 -> 1 ACTION BUTTON (inside bottom total tray)
   ============================================================ */
.exchange-btn {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 6px;
  min-height: 36px;
  background: #fff8e6;
  border: 2px solid var(--exchange-amber);
  border-radius: 6px;
  box-shadow: 0 3px 0 rgba(140, 78, 10, 0.28);
  font-family: var(--font-main);
  font-size: 14px;
  font-weight: 700;
  color: #5e3405;
  white-space: nowrap;
  cursor: pointer;
  z-index: 15;
  animation: exchangeReady 1.9s ease-in-out infinite;
  transition: transform 140ms ease, background-color 140ms ease;
}

.exchange-btn:hover {
  background: #ffefc7;
  animation: none;
  transform: translateX(-50%) scale(1.06);
}

.exchange-btn:active {
  transform: translateX(-50%) translateY(1px) scale(0.98);
}

.exchange-btn img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  display: block;
}

@keyframes exchangeReady {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-3px); }
}

/* ============================================================
   RIGHT WHITEBOARD CHECK PANEL (ONLY VISIBLE AFTER REVEAL)
   ============================================================ */
.whiteboard-check {
  flex: 0 0 250px;
  display: flex;
  align-items: center;
  animation: slideCheckIn 260ms cubic-bezier(0.22, 1, 0.36, 1);
}

.whiteboard-check[hidden] {
  display: none;
}

@keyframes slideCheckIn {
  from { opacity: 0; transform: translateX(18px); }
  to { opacity: 1; transform: translateX(0); }
}

.check-board-inner {
  width: 100%;
  background: #ffffff;
  border: 2px solid var(--line-board);
  border-radius: 10px;
  box-shadow:
    0 10px 24px rgba(24, 30, 40, 0.16),
    inset 0 0 0 3px #f2f4f8;
  padding: 14px 16px 18px;
}

.check-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1.5px solid var(--line-soft);
  padding-bottom: 8px;
  margin-bottom: 14px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-mid);
}

.check-close {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  background: #ffffff;
  color: var(--ink-mid);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.check-close:hover {
  background: #f2f4f8;
  color: var(--ink-strong);
}

.column-sum {
  display: grid;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}

.col-grid {
  display: grid;
  row-gap: 4px;
  column-gap: 4px;
  align-items: center;
  justify-items: center;
}

.col-hdr {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-muted);
  border-bottom: 2px solid var(--line-board);
  width: 100%;
  text-align: center;
  padding-bottom: 4px;
  margin-bottom: 4px;
}

.col-hdr.op-col {
  border-bottom-color: transparent;
}

.col-digit {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--ink-strong);
  min-width: 32px;
  text-align: center;
}

.col-op {
  font-size: 26px;
  font-weight: 700;
  color: var(--ink-mid);
}

.col-rule {
  grid-column: 1 / -1;
  width: 100%;
  height: 2.5px;
  background: var(--line-board);
  margin: 2px 0;
}

.col-ans {
  font-size: 32px;
  font-weight: 700;
  color: #14498a;
  line-height: 1.15;
}

.col-carry {
  font-size: 15px;
  font-weight: 700;
  color: #b84214;
  line-height: 1;
  min-height: 18px;
}

/* ============================================================
   CUSTOM EDIT MODAL
   ============================================================ */
.modal-scrim {
  position: fixed;
  inset: 0;
  background: rgba(24, 30, 38, 0.48);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  padding: 16px;
}

.modal-scrim[hidden] {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 360px;
  background: var(--paper-white);
  border: 2px solid var(--line-board);
  border-radius: 8px;
  box-shadow: 0 14px 36px rgba(15, 20, 30, 0.28);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1.5px solid var(--line-soft);
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.modal-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.edit-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.edit-row label {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-mid);
}

.edit-row input {
  font-family: var(--font-main);
  font-size: 24px;
  font-weight: 700;
  padding: 8px 12px;
  border: 1.5px solid var(--line-board);
  border-radius: 6px;
  color: var(--ink-strong);
  font-variant-numeric: tabular-nums;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

/* Share QR Modal */
.share-card {
  max-width: 390px;
}

.share-body {
  align-items: center;
  text-align: center;
  gap: 14px;
}

.qr-frame {
  width: 268px;
  height: 268px;
  background: #ffffff;
  border: 2px solid var(--line-board);
  border-radius: 6px;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.share-url-row {
  width: 100%;
  padding: 8px 10px;
  background: #f5f7fa;
  border: 1.5px solid var(--line-soft);
  border-radius: 6px;
}

.share-url-text {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-strong);
  overflow-wrap: anywhere;
  user-select: text;
  -webkit-user-select: text;
}

.share-actions {
  width: 100%;
  justify-content: center;
  margin-top: 0;
}

/* ============================================================
   FLOATING DRAG & ANIMATION FX LAYER
   ============================================================ */
.fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  overflow: hidden;
}

.drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 120;
  filter: drop-shadow(0 12px 14px rgba(18, 24, 34, 0.34));
  transform-origin: center center;
}

.fx-flyer {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 115;
}

.fx-star {
  position: fixed;
  top: 0;
  left: 0;
  width: 32px;
  height: 32px;
  object-fit: contain;
  pointer-events: none;
  z-index: 125;
}

/* Responsive tweaks for iPad Landscape (1024x768+) & compact laptops */
@media (max-width: 1180px) {
  .app-shell {
    padding: 8px 10px 10px;
    gap: 8px;
  }

  .top-bar {
    gap: 6px;
    flex-wrap: nowrap;
  }

  .level-readout {
    min-width: 98px;
    padding: 3px 6px;
  }

  .level-short {
    font-size: 14px;
  }

  .level-name {
    font-size: 11px;
  }

  .equation-card {
    padding: 4px 10px;
    gap: 5px;
  }

  .eq-num-btn,
  .eq-answer-box {
    font-size: 20px;
  }

  .eq-op {
    font-size: 20px;
  }

  .eq-answer-box {
    min-width: 56px;
    height: 36px;
    padding: 0 8px;
  }

  .action-bar {
    gap: 5px;
  }

  .tool-btn {
    padding: 4px 8px;
    font-size: 13px;
    min-height: 38px;
    gap: 5px;
  }

  .tool-btn.icon-only {
    min-width: 36px;
    padding: 4px 7px;
  }

  .share-btn .share-label {
    display: none;
  }

  .share-btn {
    min-width: 36px;
    padding: 4px 7px;
  }

  .btn-sprite {
    width: 20px;
    height: 20px;
  }

  .desk-stage {
    gap: 10px;
  }

  .bowls-rail {
    min-width: 76px;
    gap: 8px;
  }

  .wood-frame {
    padding: 11px;
  }

  /* Keep Whiteboard Check cleanly side-by-side on iPad Landscape (zero overlap over counters!) */
  .whiteboard-check {
    flex: 0 0 210px;
  }

  .check-board-inner {
    padding: 10px 12px 14px;
  }

  .col-digit {
    font-size: 25px;
    min-width: 24px;
  }

  .col-ans {
    font-size: 27px;
  }
}

/* iPad Portrait / narrow screens: place ceramic bowls in a clean horizontal shelf at the bottom
   so the wooden Place Value Board gets 100% full screen width! */
@media (max-width: 860px), (orientation: portrait) and (max-width: 1024px) {
  .top-bar {
    flex-wrap: wrap;
    justify-content: center;
  }

  .desk-stage {
    flex-direction: column-reverse;
    gap: 10px;
  }

  .bowls-rail {
    flex-direction: row;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-width: 0;
    padding: 4px 8px;
    gap: 12px;
    flex-wrap: nowrap;
  }

  .bowl-img {
    width: clamp(54px, 11vw, 76px);
    height: clamp(54px, 11vw, 76px);
  }

  .bowl-label {
    font-size: 13px;
  }

  .board-stage {
    width: 100%;
  }

  .wood-frame {
    padding: 10px;
  }

  .whiteboard-check {
    position: fixed;
    right: 12px;
    bottom: 104px;
    width: 215px;
    flex: none;
    z-index: 60;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
