/* ============================================================
   连连看 link-up · 民俗年味 / 暖木牌桌 / 喜庆绯红 / 金色流光
   ============================================================ */

:root {
  --wood-deep: #4a2c1b;
  --wood: #8a5a3b;
  --wood-light: #a9744e;
  --cream: #f7e8cf;
  --cream-hi: #fdf3de;
  --red: #d94f4f;
  --red-deep: #a93226;
  --gold: #e8b64c;
  --gold-hi: #f5d97a;
  --navy: #2e4a62;
  --ink: #4a2c1b;
  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: var(--font-stack);
  color: #3a2111;
  background:
    radial-gradient(1100px 620px at 18% -8%, rgba(232, 182, 76, 0.20), transparent 60%),
    radial-gradient(900px 560px at 108% 12%, rgba(217, 79, 79, 0.18), transparent 55%),
    radial-gradient(760px 520px at 50% 118%, rgba(46, 74, 98, 0.22), transparent 60%),
    linear-gradient(160deg, #7c5134 0%, #5f3a24 52%, #4a2c1b 100%);
  background-attachment: fixed;
  min-height: 100dvh;
  overflow-x: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* 环境光晕漂移 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(520px 300px at 30% 26%, rgba(245, 217, 122, 0.14), transparent 62%);
  animation: glow-drift 22s ease-in-out infinite alternate;
}
@keyframes glow-drift {
  0%   { transform: translate3d(-2%, -1%, 0) scale(1); }
  100% { transform: translate3d(3%, 2%, 0) scale(1.12); }
}

/* 细噪点布纹 */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.05;
  background-image:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.5) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.6) 0 1px, transparent 1px 3px);
  background-size: 3px 3px;
}

.hidden { display: none !important; }

.noscript-tip {
  max-width: 560px;
  margin: 24px auto;
  padding: 18px 22px;
  border-radius: 14px;
  background: rgba(247, 232, 207, 0.95);
  color: var(--ink);
  text-align: center;
  font-size: 15px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

/* ---------------- 舞台骨架 ---------------- */
.game-viewport {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 14px 22px 22px;
  display: flex;
  flex-direction: column;
}

/* 顶部仪式栏 */
.stage-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 12px;
}
.top-left, .top-right { display: flex; align-items: center; gap: 8px; }
.top-center { display: flex; justify-content: center; flex: 1; min-width: 0; }

.game-logo {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 3px;
  background: linear-gradient(180deg, #fdf3de 0%, var(--gold-hi) 45%, var(--gold) 78%, #b98a2e 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.4));
}

/* 通用图标按钮 */
.btn-tool {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(232, 182, 76, 0.55);
  border-radius: 10px;
  color: var(--gold-hi);
  background: linear-gradient(180deg, rgba(74, 44, 27, 0.55), rgba(58, 33, 17, 0.75));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 3px 8px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.btn-tool:hover { transform: translateY(-2px); background: linear-gradient(180deg, rgba(86, 52, 31, 0.7), rgba(64, 38, 20, 0.85)); }
.btn-tool:active { transform: translateY(1px); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); }
.btn-tool.lang-text { font-weight: 700; font-size: 13px; letter-spacing: 0.5px; }

/* 关卡匾额 */
.level-plaque {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 7px 20px;
  border-radius: 12px;
  background: linear-gradient(180deg, #c0392b 0%, #a93226 100%);
  border: 2px solid var(--gold);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.22), 0 5px 14px rgba(0, 0, 0, 0.35);
  color: #fff3dc;
  white-space: nowrap;
}
.plaque-chapter {
  font-size: 12.5px;
  letter-spacing: 3px;
  opacity: 0.92;
}
.plaque-level {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--gold-hi);
}

/* ---------------- 双栏主舞台 ---------------- */
.stage-body {
  display: flex;
  gap: 22px;
  flex: 1;
  align-items: stretch;
}

/* 左：棋盘 */
.board-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.board-frame {
  position: relative;
  --cols: 6;
  --rows: 6;
  /* 宽度计算放在有确定参照的父容器上：网格高 ≤ 100dvh-240px，再折算成含内边距的框宽 */
  width: min(100%, calc((100dvh - 240px) * var(--cols) / var(--rows) + 32px), 700px);
  padding: 16px;
  border-radius: 20px;
  background:
    repeating-linear-gradient(120deg, rgba(255, 255, 255, 0.03) 0 2px, transparent 2px 9px),
    linear-gradient(150deg, #9a6a45 0%, #6e4528 55%, #5a3720 100%);
  box-shadow:
    inset 0 2px 10px rgba(0, 0, 0, 0.4),
    inset 0 -1px 0 rgba(255, 255, 255, 0.1),
    0 0 0 2px #3e2515,
    0 0 0 4px rgba(232, 182, 76, 0.28),
    0 16px 40px rgba(0, 0, 0, 0.42);
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows), minmax(0, 1fr));
  gap: 7px;
  aspect-ratio: var(--cols) / var(--rows);
  width: 100%;
}

.fx-layer {
  position: absolute;
  inset: 16px;
  width: calc(100% - 32px);
  height: calc(100% - 32px);
  pointer-events: none;
  z-index: 3;
}

/* 棋盘格 */
.cell {
  position: relative;
  aspect-ratio: 1;
  border: none;
  border-radius: 11px;
  font-family: var(--font-stack);
  font-weight: 700;
  font-size: var(--cell-fs, 18px);
  cursor: pointer;
  color: var(--red-deep);
  background: linear-gradient(145deg, var(--cream-hi) 0%, var(--cream) 70%, #eddfc2 100%);
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.7), inset 0 -2px 4px rgba(138, 90, 59, 0.28), 0 3px 6px rgba(0, 0, 0, 0.3);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6), 0 2px 2px rgba(0, 0, 0, 0.22);
  transition: transform 0.1s ease, box-shadow 0.1s ease, opacity 0.25s ease;
  -webkit-user-select: none;
  user-select: none;
}
.cell:not(.hole):not(.empty):hover { transform: translateY(-2px); }
.cell:not(.hole):focus-visible {
  outline: 3px solid var(--gold-hi);
  outline-offset: 2px;
}
.cell.kb-focus {
  outline: 3px solid var(--gold-hi);
  outline-offset: 2px;
}

.cell.hole {
  /* Keep the grid track in place. `display:none` removes the item from CSS
     Grid auto-placement and collapses shaped-board gaps into the next cell. */
  visibility: hidden;
  pointer-events: none;
  background: transparent;
  box-shadow: none;
}

.cell.empty {
  background: rgba(58, 37, 20, 0.16);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.35);
  cursor: default;
  pointer-events: none;
}

.cell.sym-g { color: #a97612; }
.cell.sym-n { color: #2e4a62; }

/* 选中态：浮起 + 呼吸金光 */
.cell.selected {
  z-index: 2;
  transform: translateY(-3px) scale(1.05);
  box-shadow:
    inset 0 2px 3px rgba(255, 255, 255, 0.7),
    0 0 0 2px var(--gold),
    0 0 16px rgba(232, 182, 76, 0.9),
    0 6px 12px rgba(0, 0, 0, 0.35);
  animation: breathe 1.1s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.7), 0 0 0 2px var(--gold), 0 0 10px rgba(232, 182, 76, 0.65), 0 6px 12px rgba(0, 0, 0, 0.35); }
  50%      { box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.7), 0 0 0 2px var(--gold-hi), 0 0 22px rgba(245, 217, 122, 0.95), 0 6px 12px rgba(0, 0, 0, 0.35); }
}

/* 提示点亮 */
.cell.hint-glow {
  animation: hint-pulse 0.9s ease-in-out infinite;
}
@keyframes hint-pulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--gold-hi), 0 0 12px rgba(245, 217, 122, 0.75); }
  50%      { box-shadow: 0 0 0 2px #fff, 0 0 26px rgba(245, 217, 122, 1); }
}

/* 消除动画 */
.cell.removing { animation: pop-out 0.45s ease forwards; }
@keyframes pop-out {
  0%   { transform: scale(1); opacity: 1; }
  45%  { transform: scale(1.22); opacity: 1; }
  100% { transform: scale(0.3); opacity: 0; }
}
.cell.removed { visibility: hidden; pointer-events: none; }

/* 抖动（判定失败） */
.cell.shake { animation: shake 0.28s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  55% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}

.status-hint {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(58, 33, 17, 0.9);
  color: var(--gold-hi);
  font-size: 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
  z-index: 5;
}

.pause-overlay {
  position: absolute;
  inset: 16px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 13px;
  color: #fff3dc;
  text-align: center;
  background: rgba(52, 28, 15, 0.78);
  box-shadow: inset 0 0 0 1px rgba(232, 182, 76, 0.45), 0 8px 22px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(2px);
  pointer-events: none;
}
.pause-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 2px solid var(--gold-hi);
  border-radius: 50%;
  color: var(--gold-hi);
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
}
.pause-overlay strong { font-size: 20px; letter-spacing: 2px; color: var(--gold-hi); }
.pause-overlay span:last-child { font-size: 13px; color: #ead7b3; }

/* ---------------- 右侧牌匾 HUD ---------------- */
.hud-panel {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  justify-content: flex-start;
  padding-top: 6px;
}

.hud-card {
  background: linear-gradient(165deg, rgba(90, 55, 32, 0.92), rgba(64, 38, 20, 0.94));
  border: 1px solid rgba(232, 182, 76, 0.4);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 8px 20px rgba(0, 0, 0, 0.3);
}

.score-card {
  display: flex;
  align-items: baseline;
  gap: 10px;
  background: linear-gradient(180deg, #8e241f 0%, #701812 100%);
  border-color: var(--gold);
}
.hud-k { font-size: 13px; letter-spacing: 2px; color: #e8d5ae; }
.score-card .hud-k { color: #ffd98a; }
.hud-v { font-size: 22px; font-weight: 800; color: var(--gold-hi); font-variant-numeric: tabular-nums; }
.hud-max { font-size: 15px; color: #ffd98a; opacity: 0.85; font-weight: 600; }

.stat-strip { display: flex; justify-content: space-between; gap: 8px; }
.stat-item { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.stat-item .hud-v { font-size: 19px; }

/* 数值跳动 */
.bump { animation: bump 0.32s ease; }
@keyframes bump {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.4); }
  100% { transform: scale(1); }
}
.combo-bump { color: #ff6b6b; }

/* 工具台 */
.tool-dock {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.action-dock {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.tool-btn {
  padding: 12px 8px;
  border: 1px solid #b98a2e;
  border-radius: 13px;
  background: linear-gradient(180deg, var(--gold-hi) 0%, var(--gold) 60%, #dba83c 100%);
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 4px 0 #a9791f, 0 6px 14px rgba(0, 0, 0, 0.28);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.tool-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 0 #a9791f, 0 9px 18px rgba(0, 0, 0, 0.3); }
.tool-btn:active { transform: translateY(1px); box-shadow: 0 1px 0 #a9791f; }
.tool-btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

.tool-btn.ghost-btn {
  background: linear-gradient(180deg, rgba(232, 182, 76, 0.16), rgba(232, 182, 76, 0.08));
  border-color: rgba(232, 182, 76, 0.6);
  color: var(--gold-hi);
  box-shadow: 0 3px 0 rgba(90, 55, 32, 0.9), 0 5px 12px rgba(0, 0, 0, 0.25);
}
.tool-btn.ghost-btn:hover { box-shadow: 0 5px 0 rgba(90, 55, 32, 0.9), 0 8px 16px rgba(0, 0, 0, 0.3); }
.tool-btn.ghost-btn:active { box-shadow: 0 1px 0 rgba(90, 55, 32, 0.9); }

.text-link {
  border: none;
  background: none;
  color: #e8c98a;
  font-size: 13px;
  letter-spacing: 1px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 4px;
}
.text-link:hover { color: var(--gold-hi); }

/* ---------------- 弹窗 ---------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(34, 18, 8, 0.62);
  backdrop-filter: blur(4px);
  overscroll-behavior: contain;
}

.modal-card {
  width: min(440px, 100%);
  max-height: 86dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: rgba(169, 116, 78, 0.72) transparent;
  scrollbar-width: thin;
  border-radius: 18px;
  border: 2px solid var(--gold);
  background: linear-gradient(170deg, #fdf3de 0%, #f0dcb8 60%, #e6cd9f 100%);
  box-shadow: inset 0 0 0 1px rgba(74, 44, 27, 0.18), 0 24px 60px rgba(0, 0, 0, 0.5);
}
.modal-card-wide { width: min(620px, 100%); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 10px;
  position: sticky;
  top: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(253, 243, 222, 0.98), rgba(253, 243, 222, 0.9));
}
.modal-header h2 {
  font-size: 20px;
  letter-spacing: 2px;
  color: var(--ink);
}
.modal-close {
  border: none;
  background: rgba(74, 44, 27, 0.12);
  color: var(--ink);
  width: 32px;
  height: 32px;
  border-radius: 9px;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { background: rgba(74, 44, 27, 0.22); }
.modal-close:focus-visible,
.modal-btn-primary:focus-visible,
.modal-btn-secondary:focus-visible,
.modal-btn-ghost:focus-visible,
.level-btn:focus-visible,
.daily-card:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.modal-body { padding: 6px 20px 18px; }
.modal-body p { margin-bottom: 9px; line-height: 1.65; font-size: 15px; color: #5c3a26; }

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: center;
  padding: 4px 20px 18px;
}

.modal-btn-primary, .modal-btn-secondary, .modal-btn-ghost {
  padding: 11px 20px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
  border: 1px solid;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.modal-btn-primary {
  background: linear-gradient(180deg, #d94f4f, #b23a3a);
  border-color: #8e241f;
  color: #fff3dc;
  box-shadow: 0 4px 0 #7c1d18, 0 6px 14px rgba(0, 0, 0, 0.25);
}
.modal-btn-primary:hover { transform: translateY(-2px); }
.modal-btn-primary:active { transform: translateY(1px); box-shadow: 0 1px 0 #7c1d18; }

.modal-btn-secondary {
  background: linear-gradient(180deg, var(--gold-hi), var(--gold));
  border-color: #b98a2e;
  color: var(--ink);
  box-shadow: 0 4px 0 #a9791f, 0 6px 14px rgba(0, 0, 0, 0.22);
}
.modal-btn-secondary:hover { transform: translateY(-2px); }
.modal-btn-secondary:active { transform: translateY(1px); box-shadow: 0 1px 0 #a9791f; }

.modal-btn-ghost {
  background: rgba(74, 44, 27, 0.08);
  border-color: rgba(74, 44, 27, 0.35);
  color: var(--ink);
}
.modal-btn-ghost:hover { background: rgba(74, 44, 27, 0.16); }

/* 选关 */
.level-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 9px;
  margin-bottom: 16px;
}
.level-btn {
  position: relative;
  aspect-ratio: 1;
  border-radius: 12px;
  border: 1.5px solid #c08a3c;
  background: linear-gradient(180deg, #fff4dc, #eed9b0);
  color: var(--ink);
  font-weight: 800;
  font-size: 17px;
  cursor: pointer;
  box-shadow: 0 3px 0 #b98a2e, 0 5px 10px rgba(0, 0, 0, 0.18);
  transition: transform 0.1s ease;
}
.level-btn .best-tag {
  position: absolute;
  left: 3px;
  right: 3px;
  bottom: 3px;
  font-size: 9.5px;
  font-weight: 700;
  color: #a97612;
  white-space: nowrap;
  overflow: hidden;
}
.level-btn:hover { transform: translateY(-2px); }
.level-btn:active { transform: translateY(1px); }
.level-btn.locked {
  background: linear-gradient(180deg, #d8c8aa, #c4b08c);
  border-color: #a68e63;
  color: #8a7a5c;
  box-shadow: none;
  cursor: not-allowed;
}
.level-btn.locked .best-tag { color: #8a7a5c; }

.daily-card {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px;
  border-radius: 14px;
  border: 2px solid var(--gold);
  background: linear-gradient(180deg, #c0392b, #a93226);
  color: #fff3dc;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 5px 0 #7c1d18, 0 8px 18px rgba(0, 0, 0, 0.28);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.daily-card:hover { transform: translateY(-2px); }
.daily-card:active { transform: translateY(1px); box-shadow: 0 1px 0 #7c1d18; }
.daily-title { font-size: 17px; letter-spacing: 2px; }
.daily-sub { font-size: 13px; color: var(--gold-hi); font-weight: 700; }

/* 结算 */
.modal-card-accent {
  border-color: var(--gold-hi);
  background:
    radial-gradient(420px 220px at 50% -10%, rgba(232, 182, 76, 0.4), transparent 70%),
    linear-gradient(170deg, #8e241f 0%, #6e1612 70%, #5c110e 100%);
  color: #fff3dc;
}
.victory-header { justify-content: center; position: relative; }
.victory-header h2 {
  font-size: 26px;
  letter-spacing: 4px;
  color: var(--gold-hi);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}
.badge-newbest {
  position: absolute;
  top: -12px;
  right: -6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: linear-gradient(180deg, #fff3c4, var(--gold-hi));
  color: #8e241f;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
  animation: badge-pop 0.5s ease;
}
@keyframes badge-pop {
  0% { transform: scale(0); }
  70% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.win-score-line {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  font-size: 15px;
  color: #ffd98a;
}
.win-score-line strong {
  font-size: 44px;
  font-weight: 900;
  color: var(--gold-hi);
  text-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}
.win-max { color: #ffd98a; opacity: 0.8; }

.victory-stats {
  display: flex;
  gap: 12px;
  margin-top: 14px;
}
.stat-row {
  flex: 1;
  text-align: center;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 243, 220, 0.1);
  border: 1px solid rgba(232, 182, 76, 0.4);
}
.stat-row span { display: block; font-size: 12.5px; letter-spacing: 1px; color: #e8c98a; }
.stat-row strong { font-size: 22px; color: #fff3dc; }

.victory-footer { flex-wrap: wrap; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 60;
  padding: 11px 22px;
  border-radius: 999px;
  background: rgba(46, 28, 14, 0.94);
  color: var(--gold-hi);
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(232, 182, 76, 0.4);
  animation: toast-in 0.28s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(14px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---------------- 移动端（≤820px）单列紧凑 ---------------- */
@media (max-width: 820px) {
  .game-viewport { padding: 10px 10px 16px; }
  .stage-top { gap: 8px; }
  .game-logo { font-size: 18px; letter-spacing: 2px; }
  .level-plaque { padding: 5px 12px; gap: 8px; }
  .plaque-chapter { display: none; }
  .plaque-level { font-size: 14px; }

  .stage-body { flex: 0 0 auto; flex-direction: column; gap: 12px; }
  .board-panel { flex: 0 0 auto; width: 100%; }
  .board-frame { width: 100%; padding: 9px; border-radius: 14px; }
  .board-grid { width: 100%; max-width: none; }
  .fx-layer { inset: 9px; width: calc(100% - 18px); height: calc(100% - 18px); }
  .pause-overlay { inset: 9px; }

  .hud-panel {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    padding-top: 0;
  }
  .hud-card { flex: 1 1 auto; min-width: 0; padding: 10px 12px; }
  .score-card { flex-basis: 100%; justify-content: center; }
  .hud-v { font-size: 18px; }
  .tool-dock, .action-dock { flex: 1 1 46%; }
  .text-link { display: none; }

  .level-grid { grid-template-columns: repeat(4, 1fr); }
  .modal-overlay { align-items: flex-start; padding: max(12px, env(safe-area-inset-top)) 10px max(12px, env(safe-area-inset-bottom)); }
  .modal-card { max-height: calc(100dvh - 24px); }
  .modal-card-wide { width: min(620px, 100%); }
  .modal-header { padding-inline: 14px; }
  .modal-body { padding-inline: 14px; }
}

/* ---------------- 窄屏顶部重排 ---------------- */
@media (max-width: 520px) {
  .stage-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand actions"
      "plaque plaque";
    align-items: center;
    gap: 8px;
    padding-bottom: 10px;
  }
  .top-left { grid-area: brand; min-width: 0; }
  .top-center { grid-area: plaque; width: 100%; }
  .top-right { grid-area: actions; gap: 5px; }
  .game-logo {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 18px;
    letter-spacing: 2px;
  }
  .level-plaque {
    width: 100%;
    justify-content: center;
    padding: 6px 12px;
  }
}

@media (max-width: 360px) {
  .game-viewport { padding-inline: 8px; }
  .top-right { gap: 3px; }
  .top-right .btn-tool { width: 32px; height: 32px; }
  .game-logo { font-size: 16px; letter-spacing: 1px; }
  .level-plaque { font-size: 13px; }
}
/* ---------------- 动效降级 ---------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .cell.selected { transform: translateY(-3px) scale(1.05); }
  .cell.removing { animation: none !important; transition: opacity 0.2s linear; }
}



/* ---------------- Link-Up polish pass ---------------- */
@media (min-width: 821px) {
  .stage-body { align-items: flex-start; }
  .board-panel { align-items: flex-start; padding-top: 0; }
  .board-frame { margin-top: 0; }
  .hud-panel { padding-top: 0; }
}

.board-frame {
  background:
    radial-gradient(420px 180px at 50% 0%, rgba(245, 217, 122, .18), transparent 72%),
    repeating-linear-gradient(120deg, rgba(255, 255, 255, .035) 0 2px, transparent 2px 9px),
    linear-gradient(150deg, #9a6a45 0%, #6e4528 55%, #50301d 100%);
}
.board-grid { gap: 8px; }
.cell {
  overflow: visible;
  color: #c28a1b;
  background:
    radial-gradient(circle at 34% 22%, rgba(255,255,255,.8), transparent 28%),
    linear-gradient(145deg, #fff8e8 0%, #f5e5c5 68%, #e6c995 100%);
  box-shadow: inset 0 2px 3px rgba(255,255,255,.88), inset 0 -2px 4px rgba(138,90,59,.22), 0 4px 8px rgba(0,0,0,.32);
}
.cell::after {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(255,255,255,.34);
  border-radius: 8px;
  pointer-events: none;
}
.tile-art {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 13%;
  color: #bd7f13;
  filter: drop-shadow(0 2px 1px rgba(91, 43, 12, .24));
  transition: transform .16s ease, filter .16s ease;
}
.tile-art svg { display: block; width: 100%; height: 100%; overflow: visible; }
.tile-art-1, .tile-art-5, .tile-art-9, .tile-art-13 { color: #b33b32; }
.tile-art-2, .tile-art-6, .tile-art-10, .tile-art-14 { color: #2e6272; }
.tile-art-3, .tile-art-7, .tile-art-11, .tile-art-15 { color: #7c4b91; }
.cell:hover .tile-art { transform: translateY(-2px) rotate(-2deg) scale(1.05); filter: drop-shadow(0 4px 3px rgba(91,43,12,.26)); }
.cell.selected .tile-art { transform: translateY(-2px) scale(1.08); filter: drop-shadow(0 0 8px rgba(245,217,122,.95)); }
.cell.hint-glow .tile-art { animation: art-pulse .9s ease-in-out infinite; }
@keyframes art-pulse { 50% { transform: scale(1.12) rotate(3deg); filter: drop-shadow(0 0 12px rgba(255,244,176,1)); } }
.cell.empty { background: rgba(58,37,20,.22); }

.hud-panel { gap: 12px; }
.hud-card { border-radius: 18px; background: linear-gradient(145deg, rgba(76,42,24,.96), rgba(42,23,16,.96)); box-shadow: inset 0 1px 0 rgba(255,255,255,.1), inset 0 0 0 1px rgba(232,182,76,.12), 0 10px 24px rgba(0,0,0,.34); }
.score-card { position: relative; overflow: hidden; background: linear-gradient(135deg, #9f3028, #681510 78%); }
.score-card::after { content:""; position:absolute; width:110px; height:110px; right:-34px; top:-38px; border:1px solid rgba(245,217,122,.3); border-radius:50%; box-shadow:0 0 0 12px rgba(245,217,122,.06), 0 0 0 24px rgba(245,217,122,.04); }
.tool-btn { background: linear-gradient(180deg, #f7d873 0%, #d99e32 100%); border-color: rgba(255,224,133,.72); }
.action-dock .tool-btn { background: linear-gradient(180deg, rgba(255,243,208,.16), rgba(232,182,76,.08)); color: var(--gold-hi); }

/* 胜利不是普通表单：牌匾、星级、数据徽章、奖励条分层 */
.modal-card-accent { width: min(500px, 100%); overflow: hidden; border-radius: 24px; background: radial-gradient(360px 170px at 50% 0%, rgba(245,217,122,.28), transparent 70%), linear-gradient(160deg,#a7352d 0%,#711913 52%,#4d0d0b 100%); }
.victory-header { display: block; padding: 24px 24px 14px; background: transparent; text-align: center; }
.victory-heading { display: grid; gap: 5px; justify-items: center; }
.victory-kicker { color: rgba(255,243,220,.68); font-size: 10px; font-weight: 900; letter-spacing: 4px; }
.victory-header h2 { font-size: clamp(25px, 6vw, 34px); letter-spacing: 4px; }
.victory-header p { color: rgba(255,243,220,.75); font-size: 13px; }
.badge-newbest { position: static; display: inline-flex; width: fit-content; margin: 12px auto 0; padding: 6px 14px; font-size: 12px; box-shadow: 0 4px 12px rgba(0,0,0,.28); }
.victory-body { padding: 4px 24px 20px; }
.victory-rank { display: flex; justify-content: center; gap: 10px; margin: 4px 0 2px; }
.rank-star { color: rgba(255,243,220,.2); font-size: 25px; transform: scale(.85); text-shadow: 0 2px 4px rgba(0,0,0,.3); }
.rank-star.is-lit { color: var(--gold-hi); animation: star-pop .46s cubic-bezier(.2,.9,.2,1.4) both; text-shadow: 0 0 12px rgba(245,217,122,.85); }
@keyframes star-pop { from { opacity: 0; transform: scale(.2) rotate(-25deg); } to { opacity: 1; transform: scale(1) rotate(0); } }
.win-score-line { padding: 10px 0 14px; }
.win-score-line strong { font-size: clamp(50px, 12vw, 68px); line-height: .95; }
.victory-stats { gap: 8px; margin-top: 2px; }
.stat-row { min-width: 0; padding: 12px 6px; border-radius: 14px; background: rgba(35,8,6,.24); border-color: rgba(245,217,122,.35); }
.stat-row span { font-size: 11px; letter-spacing: .5px; }
.stat-row strong { font-size: 21px; }
.victory-award { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 14px; padding: 10px 12px; border-radius: 12px; color: #ffe6a4; background: rgba(245,217,122,.1); border: 1px solid rgba(245,217,122,.24); font-size: 12px; font-weight: 700; }
.award-mark { color: var(--gold-hi); font-size: 18px; }
.victory-footer { display: grid; grid-template-columns: 1fr 1.15fr; gap: 10px; padding: 4px 24px 24px; }
.victory-footer .modal-btn-ghost { grid-column: 1 / -1; padding-block: 9px; color: rgba(255,243,220,.76); border-color: rgba(255,243,220,.28); background: rgba(0,0,0,.12); }
.victory-footer .modal-btn-primary, .victory-footer .modal-btn-secondary { min-width: 0; padding-inline: 10px; }

@media (max-width: 520px) {
  .modal-card-accent { width: min(420px, 100%); border-radius: 20px; }
  .victory-header { padding: 20px 16px 10px; }
  .victory-body { padding-inline: 16px; }
  .victory-footer { padding-inline: 16px; padding-bottom: 18px; }
  .victory-stats { gap: 6px; }
  .stat-row { padding-inline: 3px; }
  .stat-row strong { font-size: 19px; }
  .tile-art { padding: 15%; }
}
@media (prefers-reduced-motion: reduce) {
  .tile-art, .cell:hover .tile-art, .cell.selected .tile-art { transition: none; transform: none; }
  .rank-star.is-lit, .cell.hint-glow .tile-art { animation: none; }
}
