/* 小挑战统一工作台：信息先于速度，反馈不遮挡下一次操作。 */
#mg-layer { overflow: hidden; padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom)); }
.mg-box.mg-app {
  box-sizing: border-box;
  width: min(100%, 600px);
  min-width: 0;
  min-height: calc(100dvh - max(8px, env(safe-area-inset-top)) - max(8px, env(safe-area-inset-bottom)));
  max-height: calc(100dvh - max(8px, env(safe-area-inset-top)) - max(8px, env(safe-area-inset-bottom)));
  overflow-x: hidden;
  overflow-y: auto;
  padding: 14px;
  border-radius: 14px;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
.mg-box.mg-app::before { display: none; }
.mg-box.mg-app .mg-head { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; flex: none; gap: 6px; min-height: 48px; padding: 8px 40px 8px 10px; margin-bottom: 12px; box-shadow: none; border-radius: 8px; }
.mg-box.mg-app .mg-title { font-size: 14px; flex: 1; min-width: 0; line-height: 1.3; }
.mg-box.mg-app .mg-score, .mg-box.mg-app .mg-timer { padding: 4px 5px; flex-shrink: 0; font-size: 12px; font-variant-numeric: tabular-nums; }
.mg-box.mg-app .mg-head > .mg-title { grid-column: 1; grid-row: 1; }
.mg-box.mg-app .mg-head > .mg-timer { grid-column: 2; grid-row: 1; }
.mg-box.mg-app .mg-head > .mg-score { grid-column: 1 / -1; grid-row: 2; justify-self: start; }
#mg-quit, #mg-exit { width: 36px !important; height: 36px !important; top: max(16px, env(safe-area-inset-top)) !important; right: max(16px, calc((100vw - 600px) / 2 + 8px)) !important; }
.mg-box .mg-intro, .mg-box .mg-result { margin: auto 0; padding: 28px 8px; }
.mg-box .mg-intro h3, .mg-box .mg-result h3 { font-size: 24px; margin: 12px 0; }
.mg-box .mg-intro p, .mg-box .mg-result p { line-height: 1.7; font-size: 15px; }
.mg-box .mg-intro .mg-exit-hint { font-size: 12px; color: var(--ink-faint); margin-top: 18px; }
.mg-box .mg-intro .btn, .mg-box .mg-result .btn { min-height: 50px; margin-top: 20px; }
.mg-box button { touch-action: manipulation; }
.mg-box button:disabled { cursor: default; }
.mgx-shell { display: flex; flex-direction: column; gap: 12px; flex: 1 0 auto; min-width: 0; }
.mgx-rule { padding: 12px; border-left: 3px solid var(--teal); background: #263b4b; color: var(--ink); border-radius: 0 7px 7px 0; font-size: 13px; line-height: 1.6; white-space: pre-line; }
.mgx-status, .mgx-progress, .mgx-rep { color: var(--ink-dim); font-size: 13px; line-height: 1.5; font-variant-numeric: tabular-nums; }
.mgx-status { padding: 10px 12px; background: #203345; border-radius: 7px; }
.mgx-grid { display: grid; grid-template-columns: 1fr; gap: 9px; }
.mgx-card { position: relative; display: flex; flex-direction: column; gap: 7px; width: 100%; min-width: 0; min-height: 88px; padding: 12px; background: #2a4053; color: var(--ink); border: 1px solid #526d82; border-bottom: 3px solid #435d73; border-radius: 9px; text-align: left; font: inherit; cursor: pointer; }
.mgx-card:hover:not(:disabled) { border-color: var(--yellow); background: #324b60; }
.mgx-card:active:not(:disabled) { transform: translateY(1px); }
.mgx-card:disabled { opacity: .65; }
.mgx-card-title { color: var(--ink); font-size: 16px; font-weight: 750; }
.mgx-card-meta { color: var(--ink-dim); font-size: 12px; line-height: 1.55; white-space: pre-line; }
.mgx-ticket { padding: 20px 16px; border: 1px solid #536574; border-radius: 8px; background: #f1eee4; color: #253443; font-size: 19px; line-height: 1.65; white-space: pre-line; }
.mgx-ticket-meta { color: #465a6b; font-size: 14px; line-height: 1.7; white-space: pre-line; }
.mgx-ticket .mgx-card-title { color: #253443; }
.mgx-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.mgx-options button { min-width: 0; min-height: 48px; white-space: normal; padding: 10px 8px; line-height: 1.4; }
.mgx-options button:last-child:nth-child(odd) { grid-column: 1 / -1; }
.mgx-talk-options { display: grid; gap: 9px; }
.mgx-answer { min-height: 68px; font-size: 15px; line-height: 1.6; justify-content: center; }
.mgx-feedback { min-height: 40px; margin-top: 3px; padding: 10px 12px; background: #233746; color: var(--ink-dim); border-radius: 7px; font-size: 14px; line-height: 1.6; white-space: pre-line; }
.mgx-feedback:empty { padding: 0; min-height: 0; }
.mgx-next { margin-top: auto; width: 100%; min-height: 50px; flex: none; }
.mgx-next[hidden] { display: none; }
.mgx-card.is-good, .mgx-feedback.is-good, .mgx-status.is-good { color: #beeed2; background: #234b3b; border-color: #6dcc9c; opacity: 1; }
.mgx-card.is-partial { color: #fff0c7; border-color: var(--yellow); opacity: 1; }
.mgx-feedback.is-partial { color: #fff0c7; background: #47412f; }
.mg-box.mg-app .mgx-next, .mg-box .mg-intro .btn-primary, .mg-box .mg-result .btn-primary { background: var(--yellow); border-color: #bc9549; color: #24303a; }
.mgx-card.is-bad, .mgx-feedback.is-bad, .mgx-status.is-bad { color: #ffd1d3; background: #4a303c; border-color: #c8757e; opacity: 1; }
.mgx-meter { position: relative; height: 62px; margin: 18px 6px; background: #132330; border: 2px solid #506d81; border-radius: 9px; overflow: hidden; flex: none; }
.mgx-zone { position: absolute; top: 0; bottom: 0; background: #387e59; border-inline: 2px solid #8bd6aa; }
.mgx-center { position: absolute; top: 0; bottom: 0; background: #f4c66b; opacity: .8; }
.mgx-needle { position: absolute; width: 5px; top: 0; bottom: 0; background: #fff; transform: translateX(-50%); box-shadow: 0 0 0 2px #17232f; }
.mgx-accuracy { font-size: 18px; line-height: 1.6; font-weight: 700; color: var(--yellow); text-align: center; min-height: 40px; }
.mgx-rep { display: flex; flex-direction: column; justify-content: center; min-height: clamp(140px, 26dvh, 250px); }
.mgx-duel { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 6px 18px; }
.mgx-duel figure { margin: 0; text-align: center; color: var(--ink-dim); font-size: 12px; }
.mgx-duel img { display: block; width: 94px; height: 110px; object-fit: cover; border-radius: 9px; border: 1px solid var(--line); margin-bottom: 5px; }
.mgx-duel strong { text-align: center; color: var(--yellow); font-size: 16px; line-height: 1.8; }
.mgx-duel small { font-size: 11px; color: var(--ink-dim); font-weight: 400; }
.mgx-replay { min-height: 44px; margin-block: 12px; }
.mgx-cue { padding: 16px 12px; background: #294b3e; border: 1px solid #6dcc9c; border-radius: 9px; color: #d0f5df; font-size: 18px; font-weight: 750; text-align: center; line-height: 1.5; }
.mgx-cue[data-phase="windup"], .mgx-cue[data-phase="warning"] { background: #494330; border-color: #f4c66b; color: #ffe7a6; }
.mgx-cue[data-phase="surge"], .mgx-cue[data-phase="rest"] { background: #453341; border-color: #c78292; color: #f7d3dc; }
.mgx-stamina { margin: 10px 0; font-size: 13px; line-height: 1.6; color: var(--ink-dim); }
.mgx-stamina > div { height: 12px; border-radius: 6px; background: #132330; overflow: hidden; }
.mgx-stamina i { display: block; height: 100%; background: #79c9a0; transition: width .1s linear; }
.mgx-hint { font-size: 13px; line-height: 1.6; color: var(--ink-dim); margin: 10px 0; }
.mgx-pause { position: absolute; z-index: 100; inset: 12px; width: calc(100% - 24px); border: 1px solid #6d889c; border-radius: 12px; color: #fff; background: #17232ff5; font: 750 20px/1.6 "PingFang SC", sans-serif; cursor: pointer; }
@media (max-height: 650px) {
  .mg-box.mg-app { padding: 10px; }
  .mg-box.mg-app .mg-head { min-height: 42px; padding-left: 7px; margin-bottom: 9px; }
  .mgx-shell { gap: 8px; }
  .mgx-rule { padding: 8px 10px; font-size: 12px; }
  .mgx-card { min-height: 72px; padding: 9px 10px; gap: 4px; }
  .mgx-ticket { padding: 12px; font-size: 16px; }
  .mgx-answer { font-size: 13px; min-height: 60px; }
  .mgx-feedback { font-size: 12px; }
  .mgx-next { min-height: 46px; }
  .mgx-meter { height: 46px; margin-block: 12px; }
  .mgx-rep { min-height: 110px; }
  .mgx-duel { padding-block: 5px 10px; }
  .mgx-duel img { width: 70px; height: 80px; }
}
@media (prefers-reduced-motion: reduce) {
  .mgx-stamina i { transition: none; }
  .mgx-card:active { transform: none; }
}

/* Repeated challenges keep the primary action close; full rules remain one tap away. */
.mg-box.mg-app .mg-intro .mgx-show-rules { display: block; width: 100%; min-height: 44px; margin-top: 10px; background: transparent; border: 1px solid var(--line); color: var(--ink-dim); }
.mg-box .mgx-quick-intro { padding-block: 18px; }
.mg-box .mgx-quick-intro .mg-emoji { font-size: 40px; }
.mg-box .mgx-intro-rules { white-space: pre-line; }
.mg-box .mgx-quick-tip { margin-bottom: 10px; }
.mg-box .mg-result .mgx-result-tip { margin-top: 16px; padding: 12px 14px; border-left: 3px solid var(--yellow); border-radius: 6px; background: var(--panel, #263b4b); color: var(--ink-dim); font-size: 14px; text-align: left; }
/* A paused challenge can be exited without first restarting its timer. */
#mg-quit, #mg-exit { z-index: 120 !important; }
/* Legacy .btn backgrounds have higher specificity than the paper card theme. */
.mg-box.mg-app .mgx-card.btn { color: #25344c; background: #fff8e8; border-color: #b7a58a; border-radius: 3px; }
.mg-box.mg-app .mgx-card.btn:hover:not(:disabled) { background: #ffedc5; border-color: #b38b45; }
.mg-box.mg-app .mgx-card.btn:disabled { opacity: .75; }
.mg-box.mg-app .mgx-card.btn.is-good { color: #20583f; background: #dcecd7; border-color: #659176; opacity: 1; }
.mg-box.mg-app .mgx-card.btn.is-partial { color: #71511e; background: #f8e5af; border-color: #b28a42; opacity: 1; }
.mg-box.mg-app .mgx-card.btn.is-bad { color: #823d36; background: #f1d9d0; border-color: #ba7669; opacity: 1; }
.mg-box.mg-app .mg-intro .mgx-show-rules { color: #586477; border-color: #b7a58a; border-radius: 3px; }
