/* ==========================================================================
   数字游乐场 · 交互页专用版式（依赖 book.css）
   ========================================================================== */

.play-page { background-image: radial-gradient(circle at 1px 1px, rgba(36, 31, 46, .04) 1px, transparent 0); }
.play-top {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 56px;
  padding: 0 clamp(14px, 3vw, 30px);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1.5px solid var(--line);
}
.play-top .crumb {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
  text-decoration: none;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1.5px solid transparent;
  white-space: nowrap;
}
.play-top .crumb:hover { background: var(--white); border-color: var(--line); color: var(--ink); }
.play-top .top-title {
  margin-left: auto;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .18em;
  color: var(--ink-3);
}
.play-top .crumb.right { margin-left: 0; }

.play-shell { width: min(1260px, 100% - 40px); margin: 0 auto; padding: 28px 0 80px; }

.play-hero { margin-bottom: 24px; }
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: .5em;
  padding: 5px 13px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  border: 1.5px solid color-mix(in srgb, var(--accent) 30%, transparent);
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: .06em;
}
.hero-badge .ic { font-size: 1.1em; }
.play-hero h1 {
  margin: .35em 0 .18em;
  font-family: var(--font-display);
  font-size: clamp(30px, 4.6vw, 48px);
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.12;
}
.play-hero .hero-sub { margin: 0; max-width: 46em; font-size: 16.5px; color: var(--ink-2); line-height: 1.85; }
.play-hero .chip-row { margin-top: 14px; }

/* 标签页 */
.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 6px;
  margin-bottom: 20px;
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-s);
}
.tab {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 14.5px;
  font-weight: 800;
  color: var(--ink-3);
  padding: 10px 16px;
  border-radius: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .45em;
  transition: background .15s, color .15s, box-shadow .15s;
}
.tab:hover { color: var(--ink); background: var(--paper-2); }
.tab.is-active { background: var(--accent); color: #fff; box-shadow: 0 3px 0 rgba(36, 31, 46, .14); }
.tab .tab-no { font-family: var(--font-serif); opacity: .75; }

.tabpanel { display: none; animation: panelIn .28s ease both; }
.tabpanel.is-active { display: block; }
@keyframes panelIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* 主舞台 */
.play-grid {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1.18fr) minmax(320px, .82fr);
  gap: 22px;
  min-width: 0;
  align-items: start;
}
.stage-card {
  min-width: 0;
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-l);
  padding: 16px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 76px;
}
.stage {
  position: relative;
  border-radius: 20px;
  background: var(--paper);
  background-image: radial-gradient(circle at 1px 1px, rgba(36, 31, 46, .06) 1px, transparent 0);
  background-size: 18px 18px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stage > svg, .stage > canvas { display: block; width: 100%; max-width: 640px; height: auto; margin-inline: auto; }
.stage > canvas { height: auto; }
.stage-note {
  padding: 12px 6px 2px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--ink-2);
  text-align: center;
  min-height: 2.6em;
}
.stage-note strong { color: var(--accent-deep); }

.panel { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card {
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-s);
}
.card-title {
  display: flex;
  align-items: center;
  gap: .5em;
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .16em;
  color: var(--ink-3);
  text-transform: uppercase;
}
.card-title .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

.control { margin: 0 0 14px; }
.control:last-child { margin-bottom: 0; }
.control-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 2px; }
.control-row label { font-size: 14px; font-weight: 800; color: var(--ink); }
.control-row output {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  color: var(--accent-deep);
  font-variant-numeric: tabular-nums;
}
.control-hint { font-size: 12.5px; color: var(--ink-3); line-height: 1.6; margin-top: 2px; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 30px;
  background: transparent;
  margin: 0;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 10px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent-soft), var(--accent-soft));
  border: 1.5px solid var(--line);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  margin-top: -9.5px;
  border-radius: 50%;
  background: var(--accent);
  border: 3.5px solid var(--white);
  box-shadow: 0 2px 8px rgba(36, 31, 46, .28);
  transition: transform .12s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.08); }
input[type="range"]:active::-webkit-slider-thumb { transform: scale(.96); }
input[type="range"]::-moz-range-track { height: 10px; border-radius: 99px; background: var(--accent-soft); border: 1.5px solid var(--line); }
input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); border: 3px solid #fff; }

input[type="number"], input[type="text"] {
  width: 100%;
  font: inherit;
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  padding: 9px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--line-2);
  background: var(--paper);
}
input[type="number"]:focus, input[type="text"]:focus { outline: 3px solid var(--sky); outline-offset: 1px; }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-block { width: 100%; }
.btn-soft {
  background: var(--accent-soft);
  color: var(--accent-deep);
  box-shadow: 0 2px 0 color-mix(in srgb, var(--accent) 30%, transparent);
}
.btn-soft:hover { background: var(--accent-soft); color: var(--accent-deep); }

/* 分段切换 */
.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--paper-2);
  border-radius: 12px;
  border: 1.5px solid var(--line);
}
.seg-btn {
  flex: 1;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink-3);
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.is-on { background: var(--white); color: var(--accent-deep); box-shadow: var(--shadow-s); }

/* 读数 */
.readout { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat {
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 13px;
  padding: 9px 12px;
  min-width: 0;
}
.stat .k { display: block; font-size: 11px; font-weight: 800; letter-spacing: .1em; color: var(--ink-3); white-space: nowrap; }
.stat .v {
  display: block;
  font-family: var(--font-serif);
  font-size: 21px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.stat .v.accent { color: var(--accent-deep); }
.stat.wide { grid-column: 1 / -1; }

.insight {
  border-left: 5px solid var(--accent);
  background: linear-gradient(100deg, var(--accent-soft), var(--white) 75%);
  border-radius: 4px var(--radius) var(--radius) 4px;
  padding: 13px 16px;
  font-size: 14.5px;
  line-height: 1.8;
}
.insight p { margin: 0; }
.insight p + p { margin-top: .5em; }
.insight strong { color: var(--accent-deep); }
.insight .big {
  display: block;
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  color: var(--accent-deep);
  margin: .1em 0 .2em;
}

.formula-card {
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-s);
  text-align: center;
}
.formula-card .math { display: block; font-size: 19px; line-height: 1.5; }
.formula-card .math .katex { font-size: 1em; }
.formula-card .cap { font-size: 11.5px; font-weight: 800; letter-spacing: .14em; color: var(--ink-3); margin-bottom: 2px; }
.formula-card .math-note { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }

/* 图例 */
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.legend .item { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }

/* 深入卡片 */
.deep { margin-top: 34px; }
.deep-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.deep-head h2 { margin: 0; font-size: clamp(21px, 2.6vw, 26px); font-weight: 800; letter-spacing: -.02em; }
.deep-head .eyebrow { margin-left: auto; }
.deep-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.deep-card {
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-s);
  font-size: 15px;
  line-height: 1.9;
}
.deep-card.wide { grid-column: 1 / -1; }
.deep-card h3 { margin: 0 0 6px; font-size: 17px; font-weight: 800; display: flex; gap: .5em; align-items: center; }
.deep-card h3 .ic { font-size: 1.15em; }
.deep-card p { margin: .55em 0; color: var(--ink-2); }
.deep-card p:last-child { margin-bottom: 0; }
.deep-card ul { margin: .5em 0; padding-left: 1.3em; color: var(--ink-2); }
.deep-card li { margin: .35em 0; }
.deep-card .formula-card { margin: .8em 0; box-shadow: none; background: var(--paper); }
.deep-card strong { color: var(--ink); }
.deep-card .warn-text { color: var(--coral-deep); font-weight: 700; }

/* 迷你验证表 */
.mini-table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin: .7em 0; font-variant-numeric: tabular-nums; }
.mini-table th, .mini-table td { padding: 5px 8px; border-bottom: 1px solid var(--line); text-align: right; }
.mini-table th:first-child, .mini-table td:first-child { text-align: left; }
.mini-table th { font-size: 11px; letter-spacing: .08em; color: var(--ink-3); font-weight: 800; }
.mini-table tr.is-hot td { background: var(--accent-soft); color: var(--accent-deep); font-weight: 800; }
.mini-table tr:last-child td { border-bottom: 0; }

/* 步骤 */
.steps { counter-reset: step; display: flex; flex-direction: column; gap: 10px; }
.step {
  position: relative;
  padding: 14px 16px 14px 52px;
  border-radius: 14px;
  background: var(--white);
  border: 1.5px solid var(--line);
  box-shadow: var(--shadow-s);
  font-size: 15px;
  line-height: 1.85;
  opacity: .42;
  transition: opacity .3s, border-color .3s, transform .3s;
}
.step::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 14px; top: 14px;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--paper-2);
  color: var(--ink-3);
  font-family: var(--font-serif);
  font-weight: 800;
  font-size: 14px;
}
.step.is-on { opacity: 1; border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); transform: translateY(-1px); }
.step.is-on::before { background: var(--accent); color: #fff; }
.step .math { font-size: 1.04em; }
.step .step-note { display: block; font-size: 12.5px; color: var(--ink-3); margin-top: 4px; }

/* 底部分页 */
.play-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 44px;
  padding-top: 22px;
  border-top: 1.5px dashed var(--line-2);
}
.play-pager a {
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  color: var(--ink-2);
  padding: 9px 14px;
  border-radius: 11px;
  border: 1.5px solid var(--line);
  background: var(--white);
}
.play-pager a:hover { border-color: var(--accent); color: var(--accent-deep); }
.play-pager .to-book { background: var(--accent); color: #fff; border-color: var(--accent); }
.play-pager .to-book:hover { color: #fff; }

/* 网格单元（筛法 / 棋盘） */
.grid-cells { display: grid; gap: 4px; padding: 10px; }
.cell {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 7px;
  background: var(--paper-2);
  border: 1.5px solid var(--line);
  font-family: var(--font-serif);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  transition: background .28s ease var(--d, 0ms), color .28s ease var(--d, 0ms), border-color .28s ease var(--d, 0ms), transform .28s ease var(--d, 0ms), opacity .2s;
}
.cell.is-crossed { background: var(--paper); color: var(--ink-3); border-color: var(--line); opacity: .58; transform: scale(.92); text-decoration: line-through; }
.cell.is-prime { background: var(--mint-soft); color: var(--mint-deep); border-color: color-mix(in srgb, var(--mint) 45%, transparent); }
.cell.is-current { background: var(--accent); color: #fff; border-color: var(--accent-deep); transform: scale(1.06); }
.cell.is-one { background: var(--paper); color: var(--ink-3); border-style: dashed; }

/* 响应式 */
@media (max-width: 980px) {
  .play-grid { grid-template-columns: 1fr; }
  .stage-card { position: static; }
  .deep-grid { grid-template-columns: 1fr; }
  .deep-card.wide { grid-column: auto; }
}
@media (max-width: 640px) {
  .play-shell { width: calc(100% - 24px); padding-top: 18px; }
  .play-top { height: 50px; padding: 0 10px; gap: 4px; }
  .play-top .top-title { display: none; }
  .play-top .crumb { font-size: 12px; padding: 6px 8px; }
  .tab { padding: 8px 11px; font-size: 13px; }
  .stage-card { padding: 8px; border-radius: 20px; }
  .readout { grid-template-columns: 1fr 1fr; }
  .stat .v { font-size: 18px; }
  .deep-card { padding: 16px; }
  .play-hero h1 { font-size: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}


/* 行内数学样式 */
.math-inline { font-family: var(--font-serif); font-weight: 600; }
.math-inline.math { font-weight: 400; }

/* 防止长公式把移动端卡片撑破 */
.deep-grid, .deep-card, .steps, .step { min-width: 0; }
.deep-card .formula-card { max-width: 100%; }
