.logic-trainer-intro { max-width: 880px; }
.logic-rules {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: -8px 0 22px;
}
.logic-rules span {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
  color: var(--muted);
  font-size: .79rem;
  line-height: 1.35;
}
.logic-rules strong { display: block; margin-bottom: 2px; color: var(--text); font-size: .86rem; }

.logic-trainer-shell {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.logic-trainer-topbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}
.logic-stat,
.logic-timer-stat {
  min-height: 72px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  padding: 15px;
  border-right: 1px solid var(--line);
}
.logic-timer-stat { background: #f8f9f3; }
.logic-stat:last-child { border-right: 0; }
.logic-stat span,
.logic-timer-stat span {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .055em;
}
.logic-stat strong,
.logic-timer-stat strong { font-size: 1.55rem; letter-spacing: -.04em; }
.logic-timer-stat em { color: var(--muted); font-size: .72rem; font-style: normal; font-weight: 700; }
.logic-timer-track { height: 5px; background: #eceee5; }
.logic-timer-track span { display: block; width: 100%; height: 100%; background: var(--accent); transform-origin: left center; transition: width .1s linear, background .15s ease; }
.logic-timer-track span.is-low { background: #ffbb64; }

.logic-game-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.48fr) minmax(300px, .52fr);
  min-height: 565px;
}
.logic-plan-panel { min-width: 0; padding: 24px; border-right: 1px solid var(--line); }
.logic-answer-panel { padding: 24px; background: #fbfcf8; }
.logic-plan-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.logic-plan-head h2 { margin: 0; font-size: 1.22rem; }
.logic-question-mark { color: #778116; }
.logic-round-tools { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .72rem; white-space: nowrap; }
.logic-round-tools strong { color: var(--text); }
.logic-reset { padding: 8px 11px; }

.logic-canvas-wrap {
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}
.logic-svg { display: block; width: 100%; max-width: 100%; height: auto; min-height: 390px; }
.logic-plan-note { margin: 10px 0 0; color: var(--muted); font-size: .74rem; line-height: 1.5; }
.logic-sketch-line { fill: none; stroke: #20261f; stroke-width: 4; stroke-linejoin: round; stroke-linecap: square; }
.logic-wall-fill { fill: #f8fbdc; stroke: #20261f; stroke-width: 3; }
.logic-opening-fill { fill: #fff; stroke: #aeb4a6; stroke-width: 1.5; stroke-dasharray: 5 5; }
.logic-centerline { stroke: #b9beb4; stroke-width: 1.3; stroke-dasharray: 7 6; }
.logic-divider { stroke: #20261f; stroke-width: 2.5; }
.logic-dim { stroke: #62695f; stroke-width: 1.5; }
.logic-dim-extension { stroke: #b7bbb2; stroke-width: 1.1; }
.logic-dim-tick { stroke: #62695f; stroke-width: 2; }
.logic-dim-text {
  fill: #333a31;
  font-size: 16px;
  font-weight: 850;
  text-anchor: middle;
  dominant-baseline: central;
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 5px;
  stroke-linejoin: round;
}
.logic-dim-text.is-missing { fill: #6f7812; font-size: 22px; font-weight: 950; }
.logic-sketch-caption { fill: #73786f; font-size: 12px; font-weight: 850; letter-spacing: .07em; }
.logic-sketch-label { fill: #5f665a; font-size: 11px; font-weight: 900; letter-spacing: .08em; text-anchor: middle; }
.logic-center-label { fill: #7c8278; font-size: 10px; font-weight: 850; letter-spacing: .055em; text-anchor: middle; }

.logic-answer-panel > .section-kicker { margin-bottom: 8px; }
.logic-answer-display {
  display: flex;
  align-items: baseline;
  gap: 9px;
  min-height: 84px;
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
}
.logic-answer-display strong { font-size: 2.25rem; letter-spacing: -.05em; }
.logic-answer-display span { color: var(--muted); font-size: .8rem; font-weight: 850; }
.logic-desktop-entry label { display: block; margin-bottom: 7px; color: var(--muted); font-size: .68rem; font-weight: 850; letter-spacing: .06em; }
.logic-answer-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.logic-answer-input:focus-within { outline: 3px solid var(--accent-soft); border-color: #9da74b; }
.logic-answer-input input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 13px 0;
  color: var(--text);
  font: inherit;
  font-size: 1.05rem;
  font-weight: 850;
}
.logic-answer-input input:disabled { color: #9b9e96; }
.logic-answer-input span { color: var(--muted); font-size: .75rem; font-weight: 850; }
.logic-desktop-entry p { margin: 7px 0 0; color: var(--muted); font-size: .7rem; }
.logic-desktop-fraction-tools {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8f9f3;
}
.logic-desktop-fraction-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.logic-desktop-fraction-heading span { color: var(--text); font-size: .62rem; font-weight: 900; letter-spacing: .055em; }
.logic-desktop-fraction-heading small { color: var(--muted); font-size: .62rem; }
.logic-desktop-fraction-pad { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.logic-desktop-fraction-pad button {
  min-height: 34px;
  padding: 5px 4px;
  border: 1px solid #cfd3ca;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: .68rem;
  font-weight: 850;
  cursor: pointer;
}
.logic-desktop-fraction-pad button:hover:not(:disabled) { border-color: #a7ad9d; background: #fbfcf8; }
.logic-desktop-fraction-pad button:focus-visible { outline: 2px solid #778116; outline-offset: 2px; }
.logic-desktop-fraction-pad button.is-selected { border-color: #778116; background: var(--accent); color: #1f251e; }
.logic-desktop-fraction-pad button:disabled { opacity: .5; cursor: default; }
.logic-mobile-entry { display: none; }

.logic-calculator-open { width: 100%; margin-top: 14px; min-height: 42px; }
.logic-calculator-note { margin: 6px 0 0; color: var(--muted); font-size: .68rem; text-align: center; }
.logic-calculator-backdrop {
  position: fixed;
  z-index: 90;
  inset: 0;
  background: rgba(24, 29, 22, .32);
  backdrop-filter: blur(1px);
}
.logic-calculator-backdrop.hidden { display: none; }
.logic-calculator-sheet {
  position: fixed;
  z-index: 100;
  right: 24px;
  bottom: 24px;
  width: min(390px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid #c9cdc3;
  border-radius: 18px;
  background: #fbfcf8;
  box-shadow: 0 22px 60px rgba(20, 24, 18, .24);
  transform: translateY(calc(100% + 40px));
  opacity: 0;
  pointer-events: none;
  transition: transform .18s ease, opacity .18s ease;
}
.logic-calculator-sheet.is-open { transform: translateY(0); opacity: 1; pointer-events: auto; }
.logic-calculator-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 15px; border-bottom: 1px solid var(--line); }
.logic-calculator-head span { display: block; color: var(--muted); font-size: .64rem; font-weight: 900; letter-spacing: .07em; }
.logic-calculator-head strong { display: block; margin-top: 2px; font-size: .79rem; }
.logic-calculator-close { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text); font-size: 1.3rem; cursor: pointer; }
.logic-calculator-display { min-height: 78px; display: flex; flex-direction: column; align-items: flex-end; justify-content: center; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #fff; }
.logic-calculator-display small { min-height: 18px; color: var(--muted); font-size: .71rem; text-align: right; }
.logic-calculator-display strong { max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-size: 1.9rem; letter-spacing: -.04em; }
.logic-calculator-input-label { padding: 9px 12px 0; color: var(--muted); font-size: .6rem; font-weight: 900; letter-spacing: .07em; }
.logic-calculator-keys { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; padding: 7px 11px 8px; }
.logic-calculator-keys button { min-height: 42px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--text); font: inherit; font-size: .88rem; font-weight: 820; cursor: pointer; }
.logic-calculator-keys button:hover { background: #f4f6ef; }
.logic-calculator-keys button[data-calc-operator],
.logic-calculator-keys .logic-calc-equals { background: #eef1e8; }
.logic-calculator-keys .logic-calc-zero { grid-column: span 2; }
.logic-calculator-keys button[data-calc-action="fraction-clear"] { font-size: .66rem; }
.logic-calculator-fraction-wrap { padding: 0 11px 10px; }
.logic-calculator-fraction-wrap .logic-calculator-input-label { padding: 2px 1px 7px; }
.logic-calculator-fraction-pad { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.logic-calculator-fraction-pad button {
  min-width: 0;
  min-height: 33px;
  padding: 5px 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: .67rem;
  font-weight: 800;
  cursor: pointer;
}
.logic-calculator-fraction-pad button.is-selected { border-color: #737e67; background: #edf1e7; }
.logic-calculator-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px 12px; border-top: 1px solid var(--line); background: #f8f9f4; }
.logic-calculator-footer span { color: var(--muted); font-size: .64rem; line-height: 1.3; }
.logic-calculator-use { min-height: 36px; padding: 7px 11px; white-space: nowrap; }
.logic-primary { width: 100%; min-height: 48px; margin-top: 14px; }
.logic-feedback {
  margin-top: 12px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: .78rem;
  line-height: 1.5;
}
.logic-feedback strong { font-weight: 900; }
.logic-feedback.is-correct { background: #f3f7d8; border-color: #d7e77d; }
.logic-feedback.is-wrong { background: #fff4f1; border-color: #efc8bf; }
.logic-feedback.is-summary { background: #f6f7f2; }
.logic-why { margin-top: 7px; }
.logic-why summary { cursor: pointer; color: #555b4f; font-weight: 850; }
.logic-why p { margin: 7px 0 0; color: #555b4f; }
.logic-trainer-shell + .resource-inline-callout { margin-top: 22px; }

@media (max-width: 920px) {
  .logic-game-grid { grid-template-columns: 1fr; }
  .logic-plan-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .logic-answer-panel { background: #fff; }
  .logic-canvas-wrap { min-width: 0; }
  .logic-svg { width: 100%; max-width: 100%; height: auto; min-height: 0; }
}

@media (max-width: 680px) {
  .logic-trainer-page { padding-top: 30px; }
  .logic-trainer-intro { margin-bottom: 18px; }
  .logic-trainer-intro h1 { font-size: clamp(2.05rem, 10.5vw, 3rem); }
  .logic-trainer-intro .lede { font-size: .9rem; line-height: 1.5; }
  .logic-rules { grid-template-columns: 1fr 1fr; gap: 7px; margin: -2px 0 14px; }
  .logic-rules span { padding: 9px 10px; font-size: .66rem; }
  .logic-rules strong { font-size: .74rem; }

  .logic-trainer-shell { border-radius: 15px; }
  .logic-trainer-topbar { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .logic-stat,
  .logic-timer-stat {
    min-height: 49px;
    gap: 3px;
    padding: 8px 4px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }
  .logic-stat span,
  .logic-timer-stat span { font-size: .54rem; letter-spacing: .035em; }
  .logic-stat strong,
  .logic-timer-stat strong { font-size: 1.12rem; line-height: 1; }
  .logic-timer-stat em { display: none; }
  .logic-timer-track { height: 4px; }

  .logic-plan-panel { padding: 10px; }
  .logic-plan-head { align-items: center; gap: 8px; }
  .logic-plan-head .section-kicker { margin-bottom: 2px; font-size: .58rem; }
  .logic-plan-head h2 { font-size: .9rem; }
  .logic-round-tools { gap: 7px; font-size: .59rem; }
  .logic-reset { padding: 6px 5px; border: 0; background: transparent; color: var(--muted); font-size: .58rem; text-decoration: underline; text-underline-offset: 2px; }
  .logic-canvas-wrap { margin-top: 8px; border-radius: 12px; }
  .logic-svg { min-height: 0; }
  .logic-plan-note { margin-top: 5px; font-size: .61rem; }
  .logic-dim-text { font-size: 14px; stroke-width: 4px; }
  .logic-dim-text.is-missing { font-size: 20px; }

  .logic-answer-panel { padding: 9px 10px 12px; }
  .logic-answer-panel > .section-kicker { display: none; }
  .logic-answer-display { justify-content: center; min-height: 50px; margin-bottom: 6px; padding: 6px 10px; }
  .logic-answer-display strong { font-size: 1.62rem; }
  .logic-answer-display span { font-size: .66rem; }
  .logic-desktop-entry { display: none; }
  .logic-mobile-entry { display: block; }
  .logic-mobile-pad {
    padding: 7px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: #f8f9f3;
    transition: opacity .12s ease;
  }
  .logic-mobile-pad.is-disabled { opacity: .48; pointer-events: none; }
  .logic-pad-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 5px; padding: 0 2px; }
  .logic-pad-heading span { color: var(--text); font-size: .56rem; font-weight: 900; letter-spacing: .05em; }
  .logic-pad-heading small { color: var(--muted); font-size: .53rem; }
  .logic-whole-pad { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; padding: 1px; }
  .logic-whole-pad button,
  .logic-fraction-pad button {
    height: 35px;
    border: 1px solid #cfd3ca;
    border-radius: 9px;
    background: #fff;
    color: var(--text);
    font: inherit;
    font-size: .7rem;
    font-weight: 850;
    cursor: pointer;
  }
  .logic-whole-pad button { width: 100%; }
  .logic-whole-pad button[data-action] { color: var(--muted); font-size: .61rem; }
  .logic-fraction-heading { margin-top: 3px; }
  .logic-fraction-pad {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
    padding: 1px;
  }
  .logic-fraction-pad button { min-width: 0; font-size: .64rem; }
  .logic-whole-pad button.is-selected,
  .logic-fraction-pad button.is-selected { border-color: #778116; background: var(--accent); color: #1f251e; }
  .logic-feedback { margin-top: 7px; padding: 8px 10px; font-size: .68rem; }
  .logic-calculator-open { margin-top: 10px; }
  .logic-calculator-note { margin-top: 4px; }
  .logic-calculator-sheet {
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 88vh;
    border-radius: 18px 18px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }
  .logic-calculator-head { padding: 10px 12px; }
  .logic-calculator-display { min-height: 64px; padding: 9px 13px; }
  .logic-calculator-display strong { font-size: 1.65rem; }
  .logic-calculator-keys button { min-height: 38px; }
  .logic-calculator-fraction-pad button { min-height: 31px; font-size: .62rem; }
  .logic-calculator-footer { padding-bottom: max(11px, env(safe-area-inset-bottom)); }
  .logic-primary { min-height: 44px; margin-top: 7px; }
}

@media (max-width: 380px) {
  .logic-rules span { font-size: .62rem; }
  .logic-plan-head h2 { font-size: .84rem; }
  .logic-round-tools > span { display: none; }
  .logic-dim-text { font-size: 13px; }
}


/* Inline trainer workbench calculator */
.logic-calculator-workbench {
  display: none;
  margin-top: 10px;
  overflow: hidden;
  border: 1px solid #c9cdc3;
  border-radius: 14px;
  background: #fbfcf8;
  box-shadow: none;
}
.logic-calculator-workbench.is-open { display: block; }
.logic-answer-panel.is-calculator-open .logic-calculator-open,
.logic-answer-panel.is-calculator-open .logic-calculator-note { display: none; }
.logic-answer-panel.is-calculator-open .logic-desktop-entry,
.logic-answer-panel.is-calculator-open .logic-mobile-entry { display: none; }
.logic-calculator-close { width: auto; height: auto; min-height: 32px; padding: 6px 10px; border-radius: 9px; font-size: .68rem; font-weight: 850; line-height: 1; }
.logic-calculator-values { padding: 9px 11px; border-bottom: 1px solid var(--line); background: #f8f9f4; }
.logic-calculator-values-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.logic-calculator-values-head span { color: var(--muted); font-size: .58rem; font-weight: 900; letter-spacing: .065em; }
.logic-calculator-values-head small { color: var(--muted); font-size: .58rem; }
.logic-calculator-value-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.logic-calculator-value-chips button { min-height: 32px; padding: 6px 8px; border: 1px solid #cfd3ca; border-radius: 9px; background: #fff; color: var(--text); font: inherit; font-size: .68rem; font-weight: 800; cursor: pointer; }
.logic-calculator-value-chips button:hover:not(:disabled) { background: #f2f5eb; border-color: #aeb5a6; }
.logic-calculator-value-chips button:disabled { opacity: .48; cursor: default; }
.logic-calculator-value-chips button span { display: block; color: var(--muted); font-size: .52rem; font-weight: 850; letter-spacing: .04em; }
.logic-calculator-value-chips button strong { display: block; margin-top: 1px; font-size: .76rem; }

@media (max-width: 680px) {
  .logic-answer-panel.is-calculator-open .logic-mobile-entry { display: none; }
  .logic-answer-panel.is-calculator-open .logic-answer-display { margin-bottom: 4px; }
  .logic-calculator-workbench { margin-top: 7px; border-radius: 11px; }
  .logic-calculator-head { padding: 8px 9px; }
  .logic-calculator-head strong { font-size: .68rem; line-height: 1.3; }
  .logic-calculator-values { padding: 7px 8px; }
  .logic-calculator-value-chips { gap: 5px; }
  .logic-calculator-value-chips button { min-height: 30px; padding: 5px 7px; }
  .logic-calculator-display { min-height: 56px; padding: 7px 10px; }
  .logic-calculator-display strong { font-size: 1.48rem; }
  .logic-calculator-keys { gap: 5px; padding: 7px 8px; }
  .logic-calculator-keys button { min-height: 35px; }
  .logic-calculator-fraction-wrap { padding: 0 8px 8px; }
  .logic-calculator-fraction-pad { gap: 4px; }
  .logic-calculator-fraction-pad button { min-height: 30px; font-size: .61rem; }
  .logic-calculator-footer { padding: 8px; }
}

.logic-calculator-workbench .logic-calculator-keys button[data-calc-action="fraction-clear"] { grid-column: span 2; }
