:root {
  --bg: #f7efe4;
  --ink: #3f3a35;
  --muted: #8d8378;
  --accent: #e98a63;
  --accent-soft: #f6c5ab;
  --card: #fffdf9;
  --line: #e9dcc9;
  --shadow: 0 10px 30px rgba(112, 87, 58, 0.10);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 4%, #ffe8d4 0, rgba(255, 232, 212, 0) 40%),
    radial-gradient(circle at 92% 0%, #e6edf1 0, rgba(230, 237, 241, 0) 36%),
    var(--bg);
  overflow: hidden;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.app {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 1440px;
  height: 100dvh;
  margin: 0 auto;
  padding: 16px clamp(14px, 2.6vw, 34px) 18px;
}

/* ---------- 顶部 ---------- */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand h1 {
  margin: 0;
  font-size: clamp(20px, 2.2vw, 28px);
  font-weight: 700;
  letter-spacing: 0.07em;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.02em;
}

.top-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.level-nav {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: rgba(255, 250, 242, 0.86);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(112, 87, 58, 0.06);
}

.music-btn {
  position: relative;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0 0 1px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 250, 242, 0.86);
  color: var(--ink);
  font: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(112, 87, 58, 0.06);
  transition: background 0.18s, color 0.18s, transform 0.18s;
}

.music-btn:hover {
  background: #fff6e9;
}

.music-btn:active {
  transform: scale(0.94);
}

.music-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.music-btn.off {
  color: var(--muted);
}

.music-btn.off::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transform: rotate(-45deg);
}

.level-arrow {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0 0 2px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
}

.level-arrow:hover:not(:disabled) {
  background: #fff6e9;
  color: var(--ink);
}

.level-arrow:disabled {
  opacity: 0.28;
  cursor: default;
}

.level-current {
  min-width: 94px;
  padding: 7px 12px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: #fffdf9;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(63, 58, 53, 0.22);
  transition: transform 0.15s, box-shadow 0.15s;
}

.level-current:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(63, 58, 53, 0.26);
}

/* ---------- 状态栏 ---------- */
.hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

.stat {
  display: flex;
  align-items: baseline;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.stat b {
  color: var(--ink);
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.progress {
  flex: 1 1 90px;
  min-width: 80px;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8dcc9;
  box-shadow: inset 0 1px 2px rgba(112, 87, 58, 0.12);
}

#progressFill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f3b28f, var(--accent));
  transition: width 0.25s linear, background 0.3s;
}

.progress.low #progressFill {
  background: linear-gradient(90deg, #ef9a83, #d9543f);
}

.time-stat.low b {
  color: #c94f3d;
}

.actions {
  display: flex;
  gap: 8px;
}

.tool-btn {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 249, 0.9);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}

.tool-btn span {
  display: inline-block;
  min-width: 1em;
  margin-left: 2px;
  color: var(--accent);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tool-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(112, 87, 58, 0.12);
}

.tool-btn:disabled {
  opacity: 0.42;
  cursor: default;
}

.tool-btn.ghost {
  background: transparent;
}

/* ---------- 棋盘 ---------- */
.board-area {
  --tile: 64px;
  --gap: 6px;
  --pad: 28px;
  position: relative;
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  padding: var(--pad);
  overflow: auto;
}

.board {
  display: grid;
  grid-template-columns: repeat(var(--cols, 8), var(--tile));
  grid-template-rows: repeat(var(--rows, 6), var(--tile));
  gap: var(--gap);
  align-content: center;
  justify-content: center;
  margin: auto;
}

.tile {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--tile);
  height: var(--tile);
  padding: 5%;
  border: 1px solid #ecdfcc;
  border-radius: 22%;
  background: var(--tile-bg, linear-gradient(155deg, #fffefb 0%, #fdf5e8 100%));
  box-shadow:
    0 3px 0 rgba(120, 95, 65, 0.10),
    0 6px 14px rgba(120, 95, 65, 0.08);
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, opacity 0.25s ease;
  touch-action: manipulation;
}

.tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 2px 2px rgba(90, 70, 50, 0.10));
}

.tile:hover {
  transform: translateY(-2px);
  border-color: #e2cfb4;
  box-shadow:
    0 5px 0 rgba(120, 95, 65, 0.09),
    0 10px 18px rgba(120, 95, 65, 0.12);
}

.tile:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tile.selected {
  z-index: 3;
  border-color: var(--accent);
  transform: translateY(-3px) scale(1.04);
  box-shadow:
    0 0 0 3px rgba(233, 138, 99, 0.22),
    0 10px 20px rgba(233, 138, 99, 0.20);
}

/* 第 40 关起的目标猫：金色光圈 + 右上角星星，远看也能找到 */
.tile.target {
  z-index: 2;
}

.tile.target::before {
  content: "";
  position: absolute;
  top: 2px;
  right: 2px;
  z-index: 4;
  width: 18px;
  height: 18px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2.4l2.9 5.9 6.5.9-4.7 4.6 1.1 6.5-5.8-3.1-5.8 3.1 1.1-6.5-4.7-4.6 6.5-.9z' fill='%23ffb300' stroke='%23fffdf9' stroke-width='1.9' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  filter: drop-shadow(0 1px 2px rgba(120, 70, 0, 0.45));
  pointer-events: none;
  animation: targetStar 1.15s ease-in-out infinite;
}

.tile.target::after {
  content: "";
  position: absolute;
  inset: 2px;
  border: 3px solid #ffb300;
  border-radius: 18%;
  box-shadow:
    0 0 0 3px rgba(255, 253, 249, 0.92),
    0 0 14px 4px rgba(255, 179, 0, 0.85),
    inset 0 0 10px rgba(255, 179, 0, 0.55);
  pointer-events: none;
  animation: targetGlow 1.15s ease-in-out infinite;
}

@keyframes targetGlow {
  0%, 100% {
    opacity: 0.85;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.04);
  }
}

@keyframes targetStar {
  0%, 100% {
    transform: scale(1) rotate(0deg);
  }
  50% {
    transform: scale(1.18) rotate(10deg);
  }
}

/* 第 50 关起的石头：固定占格，不能点、不会被消掉 */
.tile.stone {
  border-color: #b7b2a8;
  background-color: #c9c5bc;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cellipse cx='50' cy='84' rx='30' ry='6' fill='%235d5952' opacity='.28'/%3E%3Cpath d='M14 61L22 39L39 25L62 23L81 35L90 55L83 73L63 86L37 84L19 75Z' fill='%23918d85'/%3E%3Cpath d='M22 39L39 25L62 23L57 38L39 45L28 52Z' fill='%23c3bfb7'/%3E%3Cpath d='M63 24L81 35L74 47L57 38Z' fill='%23aaa69e'/%3E%3Cpath d='M14 61L22 39L28 52L27 63Z' fill='%23817d76'/%3E%3Cpath d='M19 75L37 84L63 86L83 73L79 62L61 70L41 69L26 62Z' fill='%2374706a'/%3E%3Cpath d='M46 44L52 54L47 63' fill='none' stroke='%2367635d' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M61 49L68 54' fill='none' stroke='%2367635d' stroke-width='2.2' stroke-linecap='round'/%3E%3Ccircle cx='33' cy='69' r='4' fill='%239fb287'/%3E%3Ccircle cx='39' cy='74' r='2.6' fill='%238fa175'/%3E%3C/svg%3E"),
    radial-gradient(circle at 32% 25%, #e2ded6 0%, #c4c0b7 55%, #aaa69d 100%);
  background-repeat: no-repeat, no-repeat;
  background-position: center, center;
  background-size: 88% 88%, 100% 100%;
  box-shadow:
    0 3px 0 rgba(90, 80, 66, 0.16),
    0 6px 14px rgba(90, 80, 66, 0.12),
    inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  cursor: default;
}

.tile.stone:hover {
  transform: none;
  border-color: #b7b2a8;
  box-shadow:
    0 3px 0 rgba(90, 80, 66, 0.16),
    0 6px 14px rgba(90, 80, 66, 0.12),
    inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

/* 第 60 关起的锁猫：灰一点，盖一层锁，紧挨着消一对就解开 */
.tile.locked {
  cursor: default;
}

.tile.locked img {
  filter: grayscale(0.5) brightness(0.82) drop-shadow(0 2px 2px rgba(90, 70, 50, 0.10));
}

.tile.locked:hover {
  transform: none;
}

.tile.locked::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M33 46V36Q33 18 50 18Q67 18 67 36V46' fill='none' stroke='%23fffdf9' stroke-width='9' stroke-linecap='round'/%3E%3Crect x='21' y='43' width='58' height='43' rx='12' fill='%23fffdf9'/%3E%3Ccircle cx='50' cy='61' r='7' fill='%236b5c4e'/%3E%3Crect x='46' y='64' width='8' height='13' rx='4' fill='%236b5c4e'/%3E%3C/svg%3E"),
    linear-gradient(rgba(63, 58, 53, 0.30), rgba(63, 58, 53, 0.30));
  background-repeat: no-repeat, no-repeat;
  background-position: center, center;
  background-size: 50% auto, 100% 100%;
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(40, 30, 20, 0.35));
}

.tile.unlocking {
  animation: unlockPop 0.32s ease;
}

@keyframes unlockPop {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(242, 181, 60, 0.85);
  }
  45% {
    transform: scale(1.1);
    box-shadow: 0 0 0 7px rgba(242, 181, 60, 0);
  }
  100% {
    transform: scale(1);
  }
}

.tile.hint {
  z-index: 4;
  animation: hintPulse 0.8s ease-in-out infinite;
}

.tile.wrong {
  animation: shake 0.3s ease;
}

.tile.matched {
  pointer-events: none;
  animation: pop 0.28s ease forwards;
}

.tile.empty {
  visibility: hidden;
  pointer-events: none;
}

@keyframes pop {
  0% { transform: scale(1); opacity: 1; }
  45% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(0.78); opacity: 0; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

@keyframes hintPulse {
  0%, 100% {
    box-shadow:
      0 0 0 3px rgba(255, 253, 249, 0.95),
      0 0 0 6px rgba(233, 138, 99, 0.95),
      0 0 16px 5px rgba(233, 138, 99, 0.65);
  }
  50% {
    box-shadow:
      0 0 0 4px rgba(255, 255, 255, 1),
      0 0 0 9px rgba(255, 179, 0, 1),
      0 0 26px 10px rgba(255, 179, 0, 0.85);
  }
}

/* ---------- 连线 ---------- */
.path-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.path-halo {
  fill: none;
  stroke: rgba(255, 253, 248, 0.88);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.path-main {
  fill: none;
  stroke: var(--accent);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 3px rgba(233, 138, 99, 0.35));
}

/* ---------- 加载 / 提示 ---------- */
.loading {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  background: rgba(247, 239, 228, 0.9);
  color: var(--muted);
  font-size: 15px;
  letter-spacing: 0.08em;
  transition: opacity 0.2s;
}

.loading.hidden {
  display: none;
}

/* ---------- 无解自动重排 ---------- */
.shuffle-notice {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(247, 239, 228, 0.62);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: noticeFade 0.2s ease;
}

.shuffle-notice[hidden] {
  display: none;
}

.shuffle-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 22px 32px 20px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 22px;
  background: var(--card);
  box-shadow: 0 18px 50px rgba(63, 48, 33, 0.22);
  text-align: center;
  animation: rise 0.25s ease;
}

.shuffle-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin-bottom: 5px;
  border-radius: 50%;
  background: #fff3e3;
  color: var(--accent);
  font-size: 26px;
  line-height: 1;
  animation: shuffleSpin 0.85s linear infinite;
}

.shuffle-card b {
  font-size: 18px;
  letter-spacing: 0.04em;
}

.shuffle-card span {
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 0.03em;
}

/* 难度提升提示：停表等玩家点一下再继续，绝不会来不及看 */
.level-notice {
  position: absolute;
  top: 10px;
  left: 50%;
  z-index: 8;
  width: min(86%, 350px);
  pointer-events: auto;
  transform: translateX(-50%);
  animation: noticeDrop 0.26s ease;
}

.level-notice[hidden] {
  display: none;
}

/* 看提示期间挡住整页操作 */
.board-area.notice-open::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 7;
  background: rgba(247, 239, 228, 0.42);
  -webkit-backdrop-filter: blur(1.5px);
  backdrop-filter: blur(1.5px);
}

.notice-ok {
  margin-top: 10px;
  padding: 8px 22px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: #fffdf9;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 5px 14px rgba(63, 58, 53, 0.22);
}

.notice-ok:active {
  transform: scale(0.97);
}

.level-notice-card {
  padding: 11px 18px 12px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 14px 36px rgba(63, 48, 33, 0.2);
  text-align: center;
}

.level-notice-title {
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.level-notice-list {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: 0.02em;
}

@keyframes noticeDrop {
  from {
    opacity: 0;
    transform: translate(-50%, -10px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.board.shuffling {
  pointer-events: none;
}

.board.shuffling .tile:not(.stone) {
  animation: tileShuffle 0.9s ease-in-out;
}

@keyframes tileShuffle {
  0% { transform: scale(1) rotate(0); opacity: 1; }
  35% { transform: scale(0.82) rotate(-5deg); opacity: 0.12; }
  55% { transform: scale(0.82) rotate(5deg); opacity: 0.12; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

@keyframes shuffleSpin {
  to { transform: rotate(360deg); }
}

@keyframes noticeFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 60;
  width: max-content;
  max-width: min(320px, calc(100vw - 32px));
  padding: 3px 14px;
  border-radius: 14px;
  background: rgba(63, 58, 53, 0.94);
  color: #fffdf9;
  font-size: 13px;
  line-height: 1.35;
  text-align: center;
  white-space: normal;
  overflow-wrap: break-word;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: opacity 0.22s, transform 0.22s;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- 通关 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(63, 58, 53, 0.32);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.overlay[hidden] {
  display: none;
}

.win-card {
  width: min(380px, 100%);
  padding: 26px 30px 28px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 28px;
  background: var(--card);
  box-shadow: 0 24px 70px rgba(63, 48, 33, 0.28);
  text-align: center;
  animation: rise 0.3s ease;
}

.win-card img {
  width: 112px;
  height: 112px;
  border-radius: 26px;
  background: #fff;
  object-fit: contain;
  filter: drop-shadow(0 8px 14px rgba(90, 70, 50, 0.18));
}

.win-card h2 {
  margin: 6px 0 8px;
  font-size: 23px;
  letter-spacing: 0.06em;
}

.win-text {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.win-best {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

.win-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

.win-actions button {
  flex: 1;
  padding: 11px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.win-actions button:hover {
  transform: translateY(-1px);
}

.win-actions .primary {
  background: var(--ink);
  color: #fffdf9;
  box-shadow: 0 6px 16px rgba(63, 58, 53, 0.24);
}

.win-actions .secondary {
  border-color: var(--line);
  background: transparent;
  color: var(--ink);
}

.win-card.fail h2 {
  color: #c0553f;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- 关卡地图 ---------- */
.map-card {
  display: flex;
  flex-direction: column;
  width: min(560px, 100%);
  max-height: min(700px, calc(100dvh - 36px));
  padding: 18px 20px 16px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 26px;
  background: var(--card);
  box-shadow: 0 24px 70px rgba(63, 48, 33, 0.28);
  animation: rise 0.3s ease;
}

.map-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.map-head h2 {
  flex: 1;
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.map-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 6px;
  margin: 14px 0;
  padding: 3px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.map-btn {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffaf2;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s, border-color 0.15s;
}

.map-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: #e2cfb4;
  background: #fff3e3;
}

.map-btn.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fffdf9;
  box-shadow: 0 4px 12px rgba(63, 58, 53, 0.22);
}

.map-btn.cleared::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--accent);
}

.map-btn.active.cleared::after {
  background: var(--accent-soft);
}

.map-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.map-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.map-foot b {
  color: var(--ink);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.map-foot .primary {
  padding: 9px 24px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: #fffdf9;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(63, 58, 53, 0.2);
}

/* ---------- 小屏 ---------- */
@media (max-width: 680px) {
  .app {
    gap: 9px;
    padding:
      max(12px, env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      max(14px, env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
  }

  .brand p {
    display: none;
  }

  .top-actions {
    gap: 8px;
    margin-left: auto;
  }

  .level-nav {
    padding: 3px;
  }

  .music-btn {
    width: 38px;
    height: 38px;
    font-size: 18px;
  }

  .level-arrow {
    width: 30px;
    height: 30px;
    font-size: 18px;
  }

  .level-current {
    min-width: 86px;
    padding: 6px 10px;
    font-size: 12px;
  }

  .map-card {
    padding: 16px 14px 14px;
  }

  .map-head h2 {
    font-size: 16px;
  }

  .map-grid {
    gap: 4px;
    margin: 12px 0;
  }

  .map-btn {
    border-radius: 8px;
    font-size: 11px;
  }

  .map-btn.cleared::after {
    bottom: 3px;
    width: 3px;
    height: 3px;
    margin-left: -1.5px;
  }

  .hud {
    gap: 10px;
  }

  .stat b {
    font-size: 15px;
  }

  .actions {
    width: 100%;
  }

  .tool-btn {
    flex: 1;
    text-align: center;
  }

  .win-card {
    padding: 22px 22px 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
