/* 运算律魔法屋 · 专属样式（公共样式见 ../common/base.css） */
:root { --va: #f76707; --vb: #1c7ed6; --vc: #2f9e44; --vd: #ae3ec9; }
.v-a { color: var(--va); } .v-b { color: var(--vb); } .v-c { color: var(--vc); } .v-d, .v-n { color: var(--vd); }
.fx { font-weight: 800; white-space: nowrap; }
.fx b { font-weight: 900; }
.op { font-size: 32px; font-weight: 900; color: #b4a998; padding: 0 4px; }

/* 首页 */
.fam-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }

/* 定律卡 */
.law {
  background: linear-gradient(120deg, var(--mc-soft), #fff); border: 2px solid color-mix(in srgb, var(--mc) 30%, transparent);
  border-radius: 20px; padding: 14px 20px; margin-bottom: 16px; transition: all .3s;
}
.law.on { border-color: var(--mc); box-shadow: 0 0 0 4px color-mix(in srgb, var(--mc) 18%, transparent); transform: translateY(-2px); }
.law-title { font-weight: 800; color: var(--mc); font-size: 15px; }
.law-fx { font-size: clamp(20px, 3.2vw, 28px); margin: 4px 0; overflow-x: auto; }
.law p { margin: 4px 0 0; color: #5d5666; font-size: 14px; }
.law.small { padding: 10px 14px; margin: 0; }
.law-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 14px; }
.law-grid.three { grid-template-columns: repeat(3, 1fr); }
.law-grid.four { grid-template-columns: repeat(4, 1fr); gap: 10px; }
.law-grid .law-fx { font-size: 19px; }

.steps { display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 12px 0; font-size: 22px; font-weight: 700; }
.step { opacity: 0; animation: stepIn .4s ease forwards; }
@keyframes stepIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.bad-line { color: var(--bad); text-decoration: line-through; }
.ask { display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; }
.ask .q-input { width: 110px; font-size: 20px; font-weight: 800; }
.dchip { display: inline-block; padding: 4px 12px; border-radius: 99px; background: #f2eee8; font-weight: 700; font-size: 14px; }
.dchip.up { background: #e8f8ef; color: var(--good); }
.dchip.down { background: #fff0ef; color: var(--bad); }
.story { display: flex; gap: 12px; align-items: center; font-size: 17px; background: #faf7f2; border-radius: 16px; padding: 12px 16px; margin-bottom: 14px; }
.story-icon { font-size: 40px; }

/* 方块 */
.blk-row { display: flex; flex-wrap: wrap; gap: 4px; max-width: 220px; justify-content: center; }
.blk { width: 20px; height: 20px; border-radius: 5px; box-shadow: inset 0 -3px 0 rgba(0,0,0,.15); animation: pop .3s; }
.blk:nth-child(5n) { margin-right: 6px; }
.blk.a { background: #ffa94d; } .blk.b { background: #74c0fc; } .blk.c { background: #8ce99a; }
.blk.emo { width: auto; height: auto; box-shadow: none; font-size: 20px; line-height: 1; }
.swap-stage { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; min-height: 150px; padding: 16px 0; }
.grp { background: #fff; border: 3px solid; border-radius: 18px; padding: 10px 14px; display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 120px; }
.grp.a { border-color: #ffa94d; background: #fff4e6; } .grp.b { border-color: #74c0fc; background: #e7f5ff; }
.grp-num { font-size: 26px; font-weight: 900; }
.grp.a .grp-num { color: var(--va); } .grp.b .grp-num { color: var(--vb); }

/* 结合律数字块 */
.assoc-stage { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; min-height: 120px; padding: 10px 0; }
.ntile { font-size: 34px; font-weight: 900; padding: 10px 18px; border-radius: 16px; background: #fff; border: 3px solid; }
.ntile.a { color: var(--va); border-color: #ffc078; } .ntile.b { color: var(--vb); border-color: #a5d8ff; } .ntile.c { color: var(--vc); border-color: #b2f2bb; }
.brk { position: relative; display: flex; align-items: center; gap: 8px; padding: 10px 14px 24px; border: 3px dashed var(--mc); border-radius: 24px; background: var(--mc-soft); animation: pop .4s; }
.brk small { position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%); font-weight: 800; color: var(--mc); white-space: nowrap; }

/* 配对游戏 */
.pg-board { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin: 16px 0; min-height: 90px; }
.pg-tile {
  min-width: 96px; padding: 12px 16px; border-radius: 18px; border: 3px solid var(--line); background: #fff; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; transition: all .15s; box-shadow: 0 4px 0 #e6dccd;
}
.pg-tile b { font-size: 30px; }
.pg-tile small { color: var(--muted); font-size: 12px; }
.pg-tile:hover { border-color: var(--mc); transform: translateY(-2px); }
.pg-tile.sel { border-color: var(--mc); background: var(--mc-soft); transform: translateY(-4px) scale(1.05); }
.pg-tile.merged { background: #e8f8ef; border-color: #8fd9b3; animation: pop .4s; }
.pg-expr { text-align: center; font-size: 20px; font-weight: 700; color: #5d5666; min-height: 30px; word-break: break-all; }
.pg-final { font-size: 20px; font-weight: 800; margin: 6px 0; word-break: break-all; }

/* 和的变化 */
.sum-bars { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.sum-row { display: flex; align-items: center; gap: 10px; }
.sum-lab { width: 40px; font-weight: 700; color: var(--muted); font-size: 14px; }
.sum-track { flex: 1; display: flex; align-items: center; height: 44px; }
.sum-seg { height: 100%; display: grid; place-items: center; color: #fff; font-weight: 800; transition: width .35s; overflow: hidden; }
.sum-seg.a { background: #ff922b; border-radius: 12px 0 0 12px; } .sum-seg.b { background: #4dabf7; border-radius: 0 12px 12px 0; }
.sum-row.ghost .sum-seg { opacity: .35; }
.sum-track em { font-style: normal; font-weight: 800; padding-left: 10px; white-space: nowrap; }
.sum-track em.chg { color: var(--mc); }
.adj-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; margin: 12px 0; }
.adj { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; background: #faf7f2; border-radius: 14px; padding: 8px 12px; }
.adj > b { width: 100%; font-size: 14px; }

/* 搬一搬 */
.move-stage { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.pile { min-width: 110px; padding: 12px 16px; border-radius: 18px; border: 3px solid var(--line); background: #fff; text-align: center; transition: all .25s; }
.pile b { display: block; font-size: 36px; line-height: 1.1; }
.pile small { color: var(--muted); font-weight: 700; }
.pile.a b { color: var(--va); } .pile.b b { color: var(--vb); }
.pile.round { border-color: var(--good); background: #e8f8ef; animation: pop .4s; }
.pile.round small { color: var(--good); }
.pile.sum { background: var(--mc-soft); border-style: dashed; border-color: var(--mc); }

/* 减法：剪纸条 */
.cut-track { display: flex; height: 64px; border-radius: 14px; overflow: visible; margin: 18px 0 30px; background: #f1ece4; }
.cseg { position: relative; height: 100%; display: grid; place-items: center; font-weight: 800; font-size: 13px; transition: all .5s; color: #fff; }
.cseg span { white-space: nowrap; padding: 0 4px; }
.cseg.b { background: #ff922b; } .cseg.c { background: #4dabf7; }
.cseg.cut { opacity: .28; transform: translateY(14px); background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.5) 0 6px, transparent 6px 12px); }
.cseg.rest { background: #dfd6c9; color: #8a7f70; border-radius: 0 14px 14px 0; flex: 1; }
.cseg.rest.show { background: #51cf66; color: #fff; }
.cseg:first-child { border-radius: 14px 0 0 14px; }
.cgroup { position: relative; display: flex; height: 100%; }
.cgroup.cut { transform: translateY(14px); }
.cgroup.cut .cseg { opacity: .35; background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.5) 0 6px, transparent 6px 12px); }
.cgroup .cseg:first-child { border-radius: 14px 0 0 14px; }
.cgroup em { position: absolute; left: 0; right: 0; bottom: -28px; text-align: center; font-style: normal; font-weight: 800; color: var(--mc); border-top: 3px solid var(--mc); padding-top: 2px; font-size: 13px; }
.money-track { display: flex; height: 60px; margin: 16px 0; }
.mseg { height: 100%; display: grid; place-items: center; font-weight: 800; color: #fff; transition: all .5s; position: relative; z-index: 1; }
.mseg span { white-space: nowrap; font-size: 13px; padding: 0 4px; }
.mseg.keep { background: #ffd43b; color: #7a5b00; }
.mseg.keep:first-child { border-radius: 14px 0 0 14px; }
.mseg.paid { background: repeating-linear-gradient(45deg, #ffc9c9 0 8px, #ffe3e3 8px 16px); color: #c92a2a; border-radius: 0 14px 14px 0; }
.mseg.back { background: #51cf66; z-index: 2; border-radius: 0 14px 14px 0; animation: backIn .6s ease; }
.mseg.lost { background: #e03131; z-index: 2; border-radius: 0 14px 14px 0; animation: backIn .6s ease; }
@keyframes backIn { from { transform: translateY(-40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* 差：两根条 */
.dbars { margin: 12px 0; display: flex; flex-direction: column; gap: 8px; }
.drow { display: flex; align-items: center; gap: 10px; }
.dlab { width: 56px; font-size: 14px; font-weight: 700; color: var(--muted); text-align: right; }
.dtrack { flex: 1; height: 42px; }
.dbar { position: relative; height: 100%; border-radius: 12px; transition: width .35s; display: flex; align-items: center; justify-content: flex-end; }
.dbar > b { position: relative; z-index: 1; color: #fff; font-weight: 900; padding: 0 10px; }
.dbar.a { background: #9775fa; }
.dbar.b { background: #ff922b; }
.dgap { position: absolute; top: -6px; bottom: -6px; right: 0; border: 3px dashed #2f9e44; border-radius: 12px; background: repeating-linear-gradient(45deg, rgba(81,207,102,.45) 0 6px, transparent 6px 12px); transition: left .35s; }
.dgap span { position: absolute; top: -24px; left: 50%; transform: translateX(-50%); color: #2f9e44; font-weight: 800; font-size: 14px; white-space: nowrap; }
.dbars { padding-top: 22px; }
.age-faces { display: flex; justify-content: center; gap: 40px; margin: 6px 0; }
.age-face { display: flex; flex-direction: column; align-items: center; }
.age-face span { font-size: 60px; line-height: 1.1; transition: transform .3s; }
.age-face b { font-size: 17px; }

/* 乘法：点阵 */
.dots-wrap { display: grid; place-items: center; min-height: 300px; padding: 10px; overflow: hidden; }
.dots { display: grid; gap: 4px; transition: transform .7s cubic-bezier(.4,1.4,.5,1); }
.dots.turn { transform: rotate(90deg); }
.dot { width: 30px; height: 30px; display: grid; place-items: center; font-size: 22px; animation: pop .3s backwards; }
.boxes { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin: 12px 0; }
.box { border: 3px solid #c9b9a4; background: #fbf6ee; border-radius: 14px; padding: 6px 8px 8px; transition: all .3s; }
.box small { display: block; text-align: center; color: var(--muted); font-weight: 700; font-size: 12px; }
.box.hi { border-color: var(--mc); background: var(--mc-soft); transform: translateY(-4px); box-shadow: 0 6px 16px rgba(0,0,0,.1); }
.brow { display: flex; gap: 2px; padding: 2px 4px; border-radius: 8px; transition: background .3s; font-size: 20px; }
.brow.hi { background: #ffe066; box-shadow: 0 0 0 2px #fab005; }

/* 分配律：长方形 */
.rect-wrap { display: grid; place-items: center; padding: 10px 0; overflow-x: auto; }
.rect { display: flex; align-items: flex-end; gap: 0; transition: gap .4s; }
.rect.split { gap: 26px; }
.rleft { align-self: center; padding-right: 8px; font-weight: 800; font-size: 18px; margin-top: 26px; }
.rcol { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.rtop { font-weight: 800; font-size: 18px; }
.rpart { --cell: 26px; display: grid; grid-auto-rows: var(--cell); border: 3px solid; }
.rpart span { border: 1px solid rgba(255,255,255,.8); display: grid; place-items: center; font-size: 15px; }
.rpart.a { background: #ffc078; border-color: #f76707; } .rpart.b { background: #a5d8ff; border-color: #1c7ed6; }
.rect:not(.split) .rcol:nth-child(2) .rpart { border-right: none; }
.rect:not(.split) .rcol:nth-child(3) .rpart { border-left: 2px dashed #555; }
.two-ways { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0; }
.way { background: #faf7f2; border-radius: 16px; padding: 10px; text-align: center; border: 2px solid transparent; transition: all .3s; }
.way.on { border-color: var(--mc); background: var(--mc-soft); }
.way .steps { font-size: 19px; }
.rect-mini { display: flex; height: 70px; margin: 12px auto; max-width: 560px; border-radius: 12px; overflow: hidden; }
.rm { display: grid; place-items: center; font-weight: 800; color: #fff; font-size: 15px; animation: pop .4s; white-space: nowrap; }
.rm.a { background: #51cf66; } .rm.b { background: #339af0; }
.rect-mini.minus .rm.b { background: repeating-linear-gradient(45deg, #adb5bd 0 6px, #ced4da 6px 12px); color: #343a40; margin-left: -18%; z-index: 1; }

/* 知识卡 */
.kn-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 14px; }
.kn-law { border: 2px solid #a5d8ff; border-radius: 16px; padding: 12px 16px; }
.kn-law h3 { background: #66d9e8; display: inline-block; padding: 2px 10px; border-radius: 6px; font-size: 16px; margin-bottom: 6px; }
.kn-item { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.kn-item:last-child { border-bottom: none; }
.kn-item .fx { color: #c92a2a; font-size: 17px; white-space: normal; }
.kn-item p { margin: 2px 0 0; font-size: 14px; color: #5d5666; }

@media (max-width: 860px) {
  .fam-grid, .law-grid, .law-grid.three { grid-template-columns: 1fr; }
  .law-grid.four { grid-template-columns: 1fr 1fr; }
  .kn-list { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .two-ways { grid-template-columns: 1fr; }
  .ntile { font-size: 26px; padding: 8px 12px; }
  .pile { min-width: 84px; padding: 8px 10px; }
  .pile b { font-size: 26px; }
  .dot { width: 24px; height: 24px; font-size: 18px; }
  .rpart { --cell: 20px; }
  .law-grid.four { grid-template-columns: 1fr; }
  .age-face span { font-size: 46px; }
}
