/* 一步一杯 · 小游戏(games.js)——全部 mg- 前缀,画在奶油色卡片里(墨色字) */

.mg {
  position: relative;
  display: flex; flex-direction: column; gap: 10px;
  color: var(--ink); text-align: center;
  font-family: var(--body);
  -webkit-user-select: none; user-select: none;
}
.mg b { font-weight: 800; }

/* ---------- 顶栏:轮到谁 / 结果横幅 ---------- */
.mg-head { min-height: 46px; display: flex; align-items: center; justify-content: center; }
.mg-turn {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  padding: 5px 16px 5px 5px; border-radius: 999px;
  background: var(--cream2); box-shadow: inset 0 0 0 2px var(--cream3);
  font-size: 17px; line-height: 1.2;
  animation: mg-pop .32s cubic-bezier(.3, 1.5, .5, 1) both;
}
.mg-turn-t { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mg-banner {
  display: inline-flex; align-items: center; justify-content: center; max-width: 100%;
  padding: 9px 18px; border-radius: 18px;
  background: var(--red); color: #fff;
  font-size: 19px; font-weight: 800; line-height: 1.3; text-wrap: balance;
  box-shadow: 0 3px 0 rgba(42, 26, 15, .22);
  animation: mg-pop .4s cubic-bezier(.3, 1.6, .5, 1) both;
}
.mg-banner.good { background: var(--green); color: #052611; }
.mg-banner.warn { background: var(--amber); color: #2b1700; }
.mg-foot { min-height: 21px; font-size: 14px; line-height: 1.5; color: var(--ink2); }
.mg-foot.err { color: var(--red); font-weight: 700; }
.mg-act { min-height: 56px; display: flex; flex-direction: column; justify-content: center; }
.mg-big { min-height: 72px; font-size: 26px; border-radius: 20px; letter-spacing: 2px; }
.mg-next {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 16px; color: var(--ink2);
  animation: mg-pop .3s ease-out both;
}
.mg-next b { color: var(--ink); }

/* ---------- 通用特效 ---------- */
@keyframes mg-pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes mg-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes mg-shake {
  0%, 100% { transform: none; }
  15% { transform: translate(-7px, 2px) rotate(-1.5deg); }
  30% { transform: translate(7px, -2px) rotate(1.5deg); }
  45% { transform: translate(-5px, 1px) rotate(-1deg); }
  60% { transform: translate(5px, -1px) rotate(1deg); }
  80% { transform: translate(-2px, 0); }
}
.mg-shake { animation: mg-shake .5s linear; }
.mg-flash {
  position: absolute; inset: -6px; z-index: 5; border-radius: 22px; pointer-events: none;
  background: radial-gradient(circle at 50% 50%, #fffbe8 0%, #ffd36b 30%, rgba(255, 138, 42, .75) 55%, rgba(229, 83, 75, 0) 78%);
  animation: mg-flash .9s ease-out forwards;
}
@keyframes mg-flash {
  0% { opacity: 0; transform: scale(.4); }
  12% { opacity: 1; transform: scale(1.04); }
  100% { opacity: 0; transform: scale(1.15); }
}
.mg-boom {
  position: absolute; left: 50%; top: 50%; z-index: 6; pointer-events: none;
  font-size: 104px; line-height: 1;
  transform: translate(-50%, -50%);
  animation: mg-boom 1.1s cubic-bezier(.2, 1.4, .4, 1) forwards;
}
@keyframes mg-boom {
  0% { transform: translate(-50%, -50%) scale(.2) rotate(-20deg); opacity: 0; }
  25% { transform: translate(-50%, -50%) scale(1.25) rotate(6deg); opacity: 1; }
  70% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.1); opacity: 0; }
}
@keyframes mg-land {
  0% { transform: scale(1.25); }
  55% { transform: scale(.92); }
  100% { transform: none; }
}
.mg-land { animation: mg-land .35s ease-out; }

/* ======================= 💣 剪线 ======================= */
.mg-bomb-box {
  position: relative; padding: 12px 10px 10px; border-radius: 22px;
  background: linear-gradient(#40352f, #2b231f);
  box-shadow: 0 5px 0 #17110e, inset 0 2px 0 rgba(255, 255, 255, .09);
  transition: filter .5s;
}
.mg-bomb-box.blown { filter: saturate(.55) brightness(.75) sepia(.25); }
.mg-bomb-top { position: relative; display: flex; justify-content: center; gap: 5px; height: 58px; margin: 0 14px 10px; }
.mg-stick {
  flex: 1; max-width: 48px; border-radius: 10px;
  background: linear-gradient(90deg, #95261f, #e5534b 32%, #f58b80 48%, #cf4038 72%, #8a221c);
  box-shadow: inset 0 -7px 0 rgba(0, 0, 0, .2), inset 0 6px 0 rgba(255, 255, 255, .12);
}
.mg-tape {
  position: absolute; left: 50%; top: 50%; width: min(232px, 100%); height: 16px;
  transform: translate(-50%, -50%);
  border-radius: 3px; background: #1f1a17; box-shadow: 0 1px 0 rgba(255, 255, 255, .08);
}
.mg-led {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 7px;
  padding: 3px 12px; border-radius: 9px;
  background: #120c0a; border: 3px solid #5a4c43;
  color: #ff5b4d; font: 700 18px/1.25 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 1px; white-space: nowrap;
  text-shadow: 0 0 8px rgba(255, 70, 60, .85);
}
.mg-led::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: #ff5b4d; box-shadow: 0 0 6px #ff5b4d;
  animation: mg-blink 1s steps(2) infinite;
}
.blown .mg-led { color: #ffd36b; text-shadow: 0 0 10px rgba(255, 200, 80, .9); }
@keyframes mg-blink { 50% { opacity: .15; } }
.mg-panel {
  position: relative; padding: 0 2px; border-radius: 15px;
  background: #4d413a; box-shadow: inset 0 3px 9px rgba(0, 0, 0, .5);
}
/* 上下两条铜接线排 */
.mg-panel::before, .mg-panel::after {
  content: ""; position: absolute; left: 8px; right: 8px; height: 10px; border-radius: 5px;
  background: linear-gradient(#e0b764, #8d6a2e);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .4);
}
.mg-panel::before { top: 9px; }
.mg-panel::after { bottom: 9px; }
.mg-panels { display: flex; flex-direction: column; gap: 8px; }
.mg-wires { position: relative; z-index: 1; display: flex; justify-content: center; height: 188px; }
.mg-panels.two .mg-wires { height: 102px; }
.mg-wire { position: relative; flex: 0 0 calc(100% / var(--per)); min-width: 0; height: 100%; cursor: pointer; }
.mg-panels.mg-busy .mg-wire { cursor: default; pointer-events: none; }
.mg-wire:disabled { cursor: default; }
.mg-wire svg {
  position: absolute; left: 0; top: 14px; width: 100%; height: calc(100% - 28px);
  overflow: visible; filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .38));
  transition: transform .12s;
}
.mg-wire:not(:disabled):active svg { transform: scaleY(1.03); }
.mg-wire path {
  fill: none; stroke: var(--wc); stroke-width: 9px; stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  transform-box: fill-box;
  transition: transform .45s cubic-bezier(.25, 1.5, .5, 1), stroke .3s;
}
.mg-wire .mg-w1 { transform-origin: 50% 0; }
.mg-wire .mg-w2 { transform-origin: 50% 100%; }
.mg-wire.cut .mg-w1 { transform: scaleY(.76) rotate(-6deg); }
.mg-wire.cut .mg-w2 { transform: scaleY(.76) rotate(6deg); }
.mg-screw {
  position: absolute; left: 50%; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff4c9, #d2a752 50%, #7a5820);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .55);
}
.mg-screw.t { top: 7px; }
.mg-screw.b { bottom: 7px; }
/* 剪断的火花 */
.mg-wire.cut::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px;
  border-radius: 50%; pointer-events: none;
  background: radial-gradient(#fff8d0, #ffbf3a 38%, rgba(255, 140, 40, 0) 70%);
  animation: mg-spark .5s ease-out forwards;
}
@keyframes mg-spark { from { transform: scale(.3); opacity: 1; } to { transform: scale(1.7); opacity: 0; } }
.mg-wtag {
  position: absolute; left: 50%; top: 42%; z-index: 2; pointer-events: none;
  padding: 1px 7px; border-radius: 999px;
  background: var(--green); color: #052611; font-size: 13px; line-height: 1.5; white-space: nowrap;
  transform: translateX(-50%); opacity: 0;
}
.mg-wire.safe .mg-wtag { animation: mg-float 1.1s ease-out forwards; }
@keyframes mg-float {
  0% { opacity: 0; transform: translate(-50%, 6px) scale(.7); }
  20% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -26px); }
}
.mg-wire.fuse path { stroke: #ffd65c; animation: mg-burn .25s steps(2) 6; }
.mg-wire.fuse::after {
  content: "🔥"; position: absolute; left: 50%; top: 50%; z-index: 2; font-size: 26px; line-height: 1;
  transform: translate(-50%, -60%); pointer-events: none;
}
@keyframes mg-burn { 50% { stroke: #ff6a2a; } }

/* ======================= 🔢 数字炸弹 ======================= */
.mg-range {
  display: flex; align-items: baseline; justify-content: center; gap: 14px;
  font: 42px/1 var(--title); letter-spacing: 1px;
}
.mg-is-number { gap: 9px; }
.mg-range span { font-size: 28px; color: var(--ink2); }
.mg-range b { font-weight: 400; min-width: 2ch; }
.mg-range b.hot { color: var(--red); animation: mg-land .45s ease-out; }
.mg-track { position: relative; height: 10px; margin: -3px 12px 0; border-radius: 5px; background: var(--cream3); overflow: hidden; }
.mg-track i {
  position: absolute; top: 0; bottom: 0; left: 0; width: 100%; border-radius: 5px;
  background: linear-gradient(90deg, var(--amber), var(--red));
  transition: left .5s ease, width .5s ease;
}
.mg-input {
  display: flex; align-items: center; justify-content: center; gap: 2px;
  height: 52px; border-radius: 16px;
  background: #fffaf0; box-shadow: inset 0 0 0 2px var(--cream3);
  font: 36px/1 var(--title); letter-spacing: 3px;
  transition: background .25s, box-shadow .25s;
}
.mg-input b { font-weight: 400; }
.mg-input .ph { color: var(--cream3); }
.mg-input span { font-size: 26px; letter-spacing: 1px; }
.mg-input .ph { font-size: 36px; }
.mg-caret { width: 3px; height: 32px; border-radius: 2px; background: var(--ink); animation: mg-blink 1s steps(2) infinite; }
.mg-input.ok { background: #e0f3e4; box-shadow: inset 0 0 0 2px var(--green); color: #1d6a35; }
.mg-input.boom { background: #fbd9d4; box-shadow: inset 0 0 0 3px var(--red); color: var(--red); }
.mg-only-t { font-family: var(--body); font-weight: 800; color: var(--red); }
.mg-pad { min-height: 204px; display: flex; flex-direction: column; justify-content: center; transition: opacity .3s; }
.mg-pad.mg-off { opacity: .4; pointer-events: none; }
.mg-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.mg-key {
  min-height: 46px; border-radius: 14px;
  background: var(--cream2); color: var(--ink);
  font-size: 24px; font-weight: 800;
  box-shadow: 0 3px 0 var(--cream3);
  transition: transform .06s;
}
.mg-key:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--cream3); }
.mg-key.del { font-size: 22px; color: var(--ink2); }
.mg-key.go { background: var(--ink); color: var(--cream); font-size: 20px; box-shadow: 0 3px 0 #000; }
.mg-key.go:active { box-shadow: 0 1px 0 #000; }
.mg-forced { animation: mg-pop .35s ease-out both; }
.mg-only { animation: mg-throb 1s ease-in-out infinite; }
@keyframes mg-throb { 50% { transform: scale(1.04); } }

/* ======================= 🎲 比点数 ======================= */
.mg-dice { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 8px; }
.mg-dcell {
  position: relative; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 8px 4px 10px; border-radius: 16px;
  background: var(--cream2);
  transition: opacity .35s, background .35s, box-shadow .35s;
}
.mg-dname { display: flex; align-items: center; gap: 5px; max-width: 100%; font-size: 14px; font-weight: 700; line-height: 1.2; }
.mg-dname span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mg-die { width: var(--ds); height: var(--ds); }
.mg-die svg { display: block; width: 100%; height: 100%; filter: drop-shadow(0 3px 0 rgba(42, 26, 15, .25)); }
.mg-dice.rolling .mg-die { animation: mg-roll .32s linear infinite; animation-delay: calc(var(--d) * -70ms); }
@keyframes mg-roll {
  0% { transform: rotate(0) translateY(0); }
  25% { transform: rotate(-16deg) translateY(-7px); }
  50% { transform: rotate(9deg) translateY(1px); }
  75% { transform: rotate(-7deg) translateY(-4px); }
  100% { transform: rotate(0) translateY(0); }
}
.mg-dtag {
  position: absolute; top: -7px; right: 6px;
  padding: 1px 8px; border-radius: 999px;
  background: var(--red); color: #fff; font-size: 12px; line-height: 1.6;
  box-shadow: 0 2px 0 rgba(42, 26, 15, .25);
  opacity: 0; transform: scale(.5); transition: opacity .25s, transform .3s cubic-bezier(.3, 1.6, .5, 1);
}
.mg-dcell.lose { background: #fbd9d4; box-shadow: inset 0 0 0 3px var(--red); }
.mg-dcell.lose .mg-die { animation: mg-shake .5s linear; }
.mg-dcell.lose .mg-dtag { opacity: 1; transform: none; }
.mg-dcell.safe { opacity: .45; }

/* ======================= ⏱️ 盲掐十秒 ======================= */
.mg-clock {
  padding: 16px 10px 12px; border-radius: 22px;
  background: var(--ink); color: var(--cream);
  box-shadow: 0 5px 0 rgba(42, 26, 15, .3);
}
.mg-clock-v { font: 66px/1.05 var(--title); letter-spacing: 2px; font-variant-numeric: tabular-nums; }
.mg-clock-sub { margin-top: 6px; font-size: 14px; color: var(--dim); }
.mg-clock.run .mg-clock-v { color: #fff; }
.mg-clock.hide .mg-clock-v { color: var(--amber); animation: mg-breathe 1.2s ease-in-out infinite; }
.mg-clock.shown .mg-clock-v { color: var(--amber); }
.mg-clock.shown .mg-clock-sub { color: var(--cream); font-weight: 700; }
@keyframes mg-breathe { 50% { opacity: .55; transform: scale(.96); } }
.mg-is-timer .mg-act { min-height: 72px; }
.mg-progress { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; min-height: 30px; }
.mg-pdot { position: relative; display: inline-flex; border-radius: 50%; transition: opacity .3s, transform .3s; opacity: .5; }
.mg-pdot.on { opacity: 1; transform: scale(1.12); box-shadow: 0 0 0 3px var(--cream), 0 0 0 5px var(--ink); }
.mg-pdot.done { opacity: 1; }
.mg-pdot.done::after {
  content: "✓"; position: absolute; right: -4px; bottom: -4px;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--green); color: #052611; font-size: 10px; font-weight: 900; line-height: 15px;
}
.mg-rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.mg-rank li {
  display: flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 3px 10px 3px 6px; border-radius: 12px;
  background: var(--cream2); font-size: 15px; text-align: left;
  animation: mg-in .3s ease-out both; animation-delay: calc(var(--i) * 60ms);
}
.mg-rank .n { width: 16px; flex: none; text-align: center; font-weight: 800; color: var(--ink2); }
.mg-rank .nm { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; font-weight: 700; }
.mg-rank .nm > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mg-rank .tm { flex: none; display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; font-variant-numeric: tabular-nums; }
.mg-rank .tm b { font-size: 16px; }
.mg-rank .tm small { font-size: 11px; color: var(--ink2); }
.mg-rank li.best { background: #dcf1e1; box-shadow: inset 0 0 0 2px var(--green); }
.mg-rank li.worst { background: #fbd9d4; box-shadow: inset 0 0 0 2px var(--red); }
.mg-badge {
  flex: none; padding: 1px 7px; border-radius: 999px;
  background: var(--red); color: #fff; font-size: 12px; font-weight: 800; line-height: 1.6; white-space: nowrap;
}
.mg-badge.good { background: var(--green); color: #052611; }

/* ======================= 🎡 命运转盘 ======================= */
.mg-wheel-wrap { position: relative; width: min(100%, 280px); aspect-ratio: 1; margin: 10px auto 2px; }
/* 阴影放在不转的外框上,不然会跟着转歪 */
.mg-wheel-wrap::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  box-shadow: 0 6px 0 rgba(42, 26, 15, .28);
}
.mg-wheel { position: relative; width: 100%; height: 100%; border-radius: 50%; will-change: transform; }
.mg-wheel svg { display: block; width: 100%; height: 100%; }
.mg-seg path { stroke: var(--cream); stroke-width: 2; stroke-linejoin: round; }
.mg-seg { transition: opacity .4s; }
.mg-seg text {
  fill: #fff; font-family: var(--body); font-weight: 800;
  text-anchor: middle; dominant-baseline: central;
  stroke: rgba(42, 26, 15, .55); stroke-width: 3px; paint-order: stroke; stroke-linejoin: round;
}
.mg-bulbs circle { fill: var(--cream); }
.mg-wheel.done .mg-seg:not(.win) { opacity: .32; }
.mg-wheel.done .mg-seg.win path { stroke: #fff; stroke-width: 4; }
.mg-pointer {
  position: absolute; left: 50%; top: -16px; z-index: 2;
  width: 36px; height: 48px; margin-left: -18px;
  transform-origin: 50% 13px;
  filter: drop-shadow(0 2px 0 rgba(42, 26, 15, .35));
}
.mg-pointer.mg-bob { animation: mg-bob .5s ease-out; }
@keyframes mg-bob { 30% { transform: translateY(-6px); } 60% { transform: translateY(2px); } }

/* ---------- 减少动态效果 ---------- */
@media (prefers-reduced-motion: reduce) {
  .mg-shake, .mg-dcell.lose .mg-die, .mg-dice.rolling .mg-die, .mg-land, .mg-range b.hot,
  .mg-clock.hide .mg-clock-v, .mg-only, .mg-pointer.mg-bob, .mg-wire.cut::before { animation: none; }
  .mg-turn, .mg-banner, .mg-next, .mg-forced, .mg-rank li { animation: mg-fadein .2s both; }
  .mg-flash { animation: mg-fadeout .8s ease-out forwards; transform: none; }
  .mg-boom { animation: mg-fadeout 1.3s ease-in forwards; }
  .mg-wire path { transition: none; }
}
@keyframes mg-fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes mg-fadeout { 0%, 40% { opacity: 1; } 100% { opacity: 0; } }
