.stack-main { --game-color: #ff6b81; max-width: 1400px; padding-top: 76px; }
.stack-heading > .icon-btn { display: inline-grid; }
.stack-top-actions { display: flex; gap: 10px; margin-left: auto; }
.stack-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; align-items: start; }
.stack-play { min-width: 0; }
.stack-hud { grid-template-columns: repeat(4, minmax(0, 1fr)) 136px; }
#restart-stack { white-space: nowrap; }
.stack-world { margin-top: 16px; height: min(65vh, 680px); min-height: 390px; }
#stack-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#stack-canvas:active { cursor: grabbing; }
.stack-coming { display: none; }
.stack-intro-layer { position: absolute; left: 18px; right: 18px; top: 46%; display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; }
.stack-intro-layer p { color: var(--bad); font-size: 12px; background: var(--a-card); flex: 0 0 100%; text-align: center; margin: 0; }
.stack-intro-layer p:empty { display: none; }
.stack-tools { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 18px 0 10px; }
.stack-tools button { min-height: 46px; }
.stack-tools .icon-btn { width: 46px; height: 46px; }
.stack-drop { background: #ff6b81 !important; color: #262842 !important; min-width: 128px; font-size: 16px !important; }
.stack-drop svg { width: 20px; height: 20px; }
.stack-tool { padding: 6px 12px; height: 46px; min-width: 50px; }
#magnet:not(:disabled) { background: #ffe1e6; }
:root[data-theme="dark"] #magnet:not(:disabled) { background: #4a2740; }
.stack-status { display: flex; justify-content: space-between; gap: 15px; min-height: 30px; font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.stack-next h2 { margin-bottom: 6px; }
.stack-next-items { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 10px 0 2px; }
.stack-next-items > div {
  display: flex; flex-direction: column; align-items: center; padding: 6px 4px 6px; border-radius: 14px; background: var(--a-soft);
  border: 2px dashed #26284233;
}
.stack-next-items > div:first-child { border: 2px solid var(--a-ink); background: #fff3c4; position: relative; }
:root[data-theme="dark"] .stack-next-items > div:first-child { background: #3b335e; }
:root[data-theme="dark"] .stack-next-items > div { border-color: #ffffff22; }
.stack-next-items > div:first-child::before {
  content: "下一个"; position: absolute; top: -10px; padding: 0 7px; font-size: 10px; font-weight: 800; border-radius: 99px;
  border: 2px solid var(--a-ink); background: var(--a-coral); color: #262842;
}
.stack-next-items canvas { height: 72px; width: 100%; }
.stack-next-items span { font-size: 11px; font-weight: 700; color: var(--ink-soft); }
.stack-rules summary { display: flex; align-items: center; gap: 9px; cursor: pointer; list-style: none; color: var(--ink); }
.stack-rules summary::-webkit-details-marker { display: none; }
.stack-rules summary > span { flex: 1; min-width: 0; }
.stack-rules summary small { display: block; margin-top: 2px; color: var(--ink-soft); font-size: 11px; font-weight: 400; font-family: "Microsoft YaHei", sans-serif !important; }
.stack-rules summary > svg { width: 18px; height: 18px; flex-shrink: 0; }
.stack-rules[open] summary > svg:last-child { transform: rotate(180deg); }
.stack-rules summary:focus-visible { outline: 2px solid var(--a-coral); outline-offset: 4px; }
.stack-rules-body { font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; }
.stack-rules-warning { margin: 14px 0; padding: 9px 11px; border-radius: 12px; background: #ffe7eb; border: 2px solid var(--a-ink); color: #4a2a35; }
:root[data-theme="dark"] .stack-rules-warning { background: #3d2440; color: #ffd9e0; }
.stack-rules-warning strong { display: block; color: inherit; margin-bottom: 4px; }
.stack-rules dl { margin: 0; }
.stack-rules dl > div + div { margin-top: 10px; }
.stack-rules dt { font-weight: 800; color: var(--ink); }
.stack-rules dt::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 3px; background: var(--a-coral); margin-right: 6px; border: 1.5px solid var(--a-ink); }
.stack-rules dl > div:nth-child(2) dt::before { background: var(--a-teal); }
.stack-rules dl > div:nth-child(3) dt::before { background: var(--a-sun); }
.stack-rules dl > div:nth-child(4) dt::before { background: var(--a-grape); }
.stack-rules dd { margin: 2px 0 0 16px; color: var(--ink-soft); }
.stack-board .board-table td { padding-block: 8px; }
.stack-board .board-empty { padding-block: 28px; }
.stack-result-heading { display: flex; gap: 15px; align-items: center; justify-content: space-between; }
#stack-register { display: flex; gap: 14px; align-items: flex-end; max-width: 480px; }
#stack-register .field { flex: 1; margin: 12px 0; }
#stack-register .action-btn { margin: 12px 0; min-height: 44px; }
.stack-result-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 14px; }
#register-status { min-height: 22px; font-size: 12px; color: var(--ink-soft); }
.stack-feature { display: flex; gap: 26px; align-items: center; }
.stack-feature canvas { width: 185px; height: 128px; flex: 0 0 185px; }
.stack-feature-copy { flex: 1; min-width: 0; }
.stack-feature h2 { margin-top: 8px; }
.stack-feature p { font-size: 13px; color: var(--ink-soft); }
.stack-feature .action-btn { margin-top: 8px; }
@media (max-width: 1024px) { .stack-layout { grid-template-columns: minmax(0, 1fr) 270px; gap: 22px; } .stack-tools { gap: 7px; } }
@media (max-width: 820px) {
  .stack-main { padding: 66px 14px 28px; }
  .stack-heading { margin-bottom: 10px; gap: 9px; }
  .stack-heading .section-label { display: none; }
  .stack-top-actions { gap: 7px; }
  .stack-layout { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .stack-hud { grid-template-columns: repeat(4, minmax(0, 1fr)) 92px; }
  #restart-stack { padding: 6px 8px; gap: 4px; font-size: 12px; min-height: 38px; }
  #restart-stack svg { width: 16px; height: 16px; }
  .stack-world { height: calc(100svh - 300px); min-height: 280px; max-height: 640px; margin-top: 10px; }
  .stack-coming {
    position: absolute; top: 7px; right: 8px; display: flex; align-items: center; gap: 4px; pointer-events: none;
    padding: 1px 9px 1px 8px; border-radius: 99px; background: #ffffffd9; border: 2px solid var(--a-ink); color: #262842; font-weight: 700;
  }
  :root[data-theme="dark"] .stack-coming { background: #1d1e3ad9; color: #f1f0ff; }
  .stack-coming span { font-size: 10px; white-space: nowrap; }
  .stack-coming canvas { width: 38px; height: 28px; }
  .stack-tools { gap: 6px; padding: 12px 0 8px; }
  .stack-tools button { min-height: 42px; }
  .stack-tools .icon-btn { width: 36px; height: 42px; min-height: 42px; border-radius: 11px; }
  .stack-tools .stack-drop { min-width: 76px; height: 42px; padding: 6px 9px; font-size: 13px !important; border-radius: 12px; }
  .stack-tool { padding: 6px; height: 42px; min-width: 40px; border-radius: 11px; }
  .stack-tool > span { top: -8px; right: -6px; min-width: 18px; height: 18px; font-size: 10px !important; }
  .stack-next { display: flex; align-items: center; gap: 15px; }
  .stack-next h2 { font-size: 15px; flex: 0 0 auto; margin: 0; }
  .stack-next-items { flex: 1; margin: 8px 0 0; }
  .stack-next-items canvas { height: 50px; }
  .stack-rules { order: -1; }
  .stack-status { font-size: 11px; gap: 8px; }
  .stack-feature { gap: 14px; }
  .stack-feature canvas { width: 104px; height: 130px; flex-basis: 104px; }
  #stack-register { gap: 10px; }
}
@media (max-width: 360px) {
  .stack-main { padding-inline: 10px; }
  .stack-tools { gap: 4px; }
  .stack-tools .icon-btn { width: 31px; }
  .stack-hud { grid-template-columns: repeat(4, minmax(0, 1fr)) 84px; }
  #restart-stack { padding-inline: 5px; }
}
