/* ============ 关卡页与棋盘 ============ */
#view-level { padding-bottom: calc(10px + var(--safe-b)); }

.icon-btn-img {
  width: 40px; height: 40px;
  padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: none; border: 0;
}
.icon-btn-img img {
  width: 100%; height: 100%;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
}
.icon-btn-img:active img { transform: scale(.94); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 40px; flex: none;
}
.topbar-title { font-family: var(--font-song); font-size: 15px; letter-spacing: .08em; color: var(--ink-2); }

.poem-card {
  flex: none;
  text-align: center;
  padding: 6px 0 10px;
}
.poem-meta { font-size: 12px; color: var(--ink-3); letter-spacing: .08em; }
.poem-line {
  margin-top: 6px;
  font-family: var(--font-song);
  font-size: 22px; letter-spacing: .12em; text-indent: .12em;
  color: var(--ink);
  line-height: 1.35;
}
.poem-line.is-dense { font-size: 18px; letter-spacing: .06em; }

.board-wrap {
  flex: 1;
  /* 棋盘位置由 JS 用整数 margin 决定，这里不能再用 center */
  display: flex; align-items: flex-start; justify-content: flex-start;
  min-height: 0;
}

.board {
  position: relative;
  border-radius: 8px;
  background: linear-gradient(180deg, #EADFC6, #E4D6B8);
  box-shadow:
    inset 0 2px 6px rgba(90, 70, 40, .18),
    0 8px 24px rgba(90, 70, 40, .12);
  padding: var(--gap);
}

.slot {
  position: absolute;
  left: 0; top: 0;
  width: var(--tile); height: var(--tile);
  will-change: transform;
  border-radius: 3px;
  background: repeating-linear-gradient(45deg, #E2D3B4, #E2D3B4 4px, #E8DCC2 4px, #E8DCC2 8px);
  box-shadow: inset 0 2px 4px rgba(90, 70, 40, .16);
}

.tile {
  position: absolute;
  width: var(--tile); height: var(--tile);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-song);
  font-size: calc(var(--tile) * .46);
  line-height: 1;
  color: var(--ink);
  background: radial-gradient(120% 90% at 30% 10%, #FFFDF6 0%, #FBF6EA 55%, #F0E4CC 100%);
  border-radius: 3px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .95),
    inset 0 -2px 0 rgba(96, 72, 40, .16),
    0 2px 5px rgba(64, 44, 24, .18);
  transform: translate3d(var(--x, 0), var(--y, 0), 0);
  transition: transform .15s cubic-bezier(.22, .61, .36, 1), box-shadow .18s ease;
  touch-action: manipulation;
  will-change: transform;
}
.tile.is-placed {
  box-shadow:
    inset 0 0 0 2px var(--gold),
    inset 0 1px 0 rgba(255, 255, 255, .9),
    0 2px 5px rgba(64, 44, 24, .18);
}
.tile.is-hint {
  animation: hintPulse .7s ease-in-out 4;
  z-index: 3;
}
@keyframes hintPulse {
  50% {
    box-shadow: 0 0 0 3px rgba(180, 54, 44, .5), 0 2px 5px rgba(64, 44, 24, .18);
  }
}
.tile.is-nudge { animation: nudge .26s ease; }
@keyframes nudge {
  25% { transform: translate3d(calc(var(--x, 0) - 3px), var(--y, 0), 0); }
  75% { transform: translate3d(calc(var(--x, 0) + 3px), var(--y, 0), 0); }
}

/* 通关时字块飞散（轻微） */
.board.is-done .tile { transition: transform .26s cubic-bezier(.34, 1.2, .64, 1), opacity .26s; }

.action-bar {
  flex: none;
  display: flex; gap: 10px;
  padding-top: 10px;
}
.action-bar .btn { flex: 1; height: 44px; }
.action-bar .btn.is-armed {
  border-color: var(--cinnabar);
  color: var(--cinnabar);
  background: rgba(180, 54, 44, .08);
}

@media (max-height: 620px) {
  .poem-line { font-size: 18px; }
  .action-bar .btn { height: 40px; }
}
