/* 天马拼图（工坊1需求版）：自由拖动拼接 + 右侧仅保留外轮廓虚线 */

.tianma-puzzle-overlay.workshop-step-game-overlay {
  background: rgba(18, 14, 12, 0.62);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.tianma-puzzle-shell {
  width: min(1480px, 98vw);
  max-height: min(96vh, 1040px);
  min-height: min(88vh, 900px);
  display: flex;
  flex-direction: column;
  border-radius: 22px;
  border: 1px solid rgba(212, 175, 95, 0.45);
  background:
    linear-gradient(145deg, rgba(255, 248, 235, 0.04) 0%, transparent 42%),
    linear-gradient(168deg, #3a2c22 0%, #261c16 55%, #1a1410 100%);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.35) inset,
    0 28px 56px rgba(0, 0, 0, 0.5),
    0 4px 24px rgba(212, 175, 95, 0.08);
  padding: 14px 16px 18px;
  position: relative;
}

.tianma-puzzle-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding-right: 40px;
  margin-bottom: 8px;
}

.tianma-puzzle-board-title {
  margin: 0;
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #f0d78c;
  font-family: "STKaiti", "KaiTi", "Songti SC", "Noto Serif SC", "PingFang SC", serif;
  text-shadow: 0 2px 2px rgba(0, 0, 0, 0.45), 0 0 22px rgba(232, 200, 120, 0.18);
}

.tianma-puzzle-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid rgba(212, 175, 95, 0.55);
  background: linear-gradient(180deg, rgba(70, 52, 40, 0.98), rgba(45, 34, 26, 0.98));
  color: #f0d78c;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  z-index: 5;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.tianma-puzzle-close:hover {
  filter: brightness(1.08);
  transform: scale(1.04);
}

.tianma-puzzle-hint {
  min-height: 28px;
  margin: 0 0 10px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(212, 175, 95, 0.28);
  background: rgba(0, 0, 0, 0.22);
  color: rgba(240, 220, 170, 0.95);
  font-size: 15px;
  line-height: 1.45;
  font-family: "STKaiti", "KaiTi", "Songti SC", serif;
}

.tianma-puzzle-hint.is-error {
  color: #ffd4c2;
  border-color: rgba(230, 120, 90, 0.45);
  background: rgba(60, 28, 20, 0.35);
}

.tianma-puzzle-hint.is-success {
  color: #c8f5b8;
  border-color: rgba(120, 200, 140, 0.5);
  background: rgba(28, 50, 32, 0.35);
}

.tianma-puzzle-mount {
  flex: 1;
  min-height: min(58vh, 560px);
  display: flex;
  flex-direction: column;
  min-width: 0;
  touch-action: none;
  overscroll-behavior: contain;
}

.tianma-puzzle-stage-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(212, 175, 95, 0.28);
  background: rgba(16, 12, 10, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  position: relative;
  contain: layout style;
  min-height: min(52vh, 520px);
}

/* 左：部件；右：平台 */
.tianma-puzzle-stage {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  width: 100%;
  flex: 1;
  min-height: min(50vh, 500px);
  touch-action: none;
}

.tianma-puzzle-tray {
  flex: 0 0 clamp(300px, 38%, 620px);
  min-width: 280px;
  display: flex;
  flex-direction: column;
  border-right: 2px solid rgba(35, 48, 42, 0.45);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, transparent 28%),
    linear-gradient(165deg, rgba(30, 38, 34, 0.35) 0%, rgba(18, 24, 22, 0.42) 100%);
  pointer-events: none;
  z-index: 0;
  box-shadow: 4px 0 14px rgba(0, 0, 0, 0.12);
}

.tianma-puzzle-tray-heading {
  flex: 0 0 auto;
  padding: 12px 12px 6px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.35em;
  text-indent: 0.35em;
  color: rgba(235, 245, 238, 0.92);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  font-family: "PingFang SC", "Noto Sans SC", sans-serif;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.tianma-puzzle-tray-inner {
  flex: 1;
  min-height: 120px;
}

.tianma-puzzle-board-area {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  z-index: 0;
  background: transparent;
}

.tianma-puzzle-board-heading {
  flex: 0 0 auto;
  padding: 12px 14px 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.35em;
  text-indent: 0.35em;
  color: rgba(250, 252, 248, 0.95);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  font-family: "PingFang SC", "Noto Sans SC", sans-serif;
}

.tianma-puzzle-board-inner {
  flex: 1;
  position: relative;
  margin: 0 10px 10px;
  border-radius: 14px;
  background: transparent;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.tianma-puzzle-stage.is-learning-targets .tianma-puzzle-board-inner {
  box-shadow:
    inset 0 0 0 1px rgba(255, 240, 175, 0.42),
    inset 0 0 24px rgba(255, 225, 132, 0.12);
}

.tianma-puzzle-silhouette-wrap {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  pointer-events: none;
  z-index: 1;
}

.tianma-puzzle-silhouette {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(62vh, 560px);
  object-fit: contain;
  opacity: 0;
  filter: none;
  transition: filter 0.6s ease, transform 0.5s ease;
}

.tianma-puzzle-silhouette.is-colorful {
  filter: saturate(1.12) brightness(1.05) contrast(1.02) drop-shadow(0 8px 18px rgba(0, 0, 0, 0.2));
}

.tianma-puzzle-silhouette-outline {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(62vh, 560px);
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 0 1px rgba(248, 218, 147, 0.72)) drop-shadow(0 0 6px rgba(248, 218, 147, 0.22));
}

.tianma-puzzle-piece {
  position: absolute;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  box-sizing: border-box;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  cursor: grab;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  transition: opacity 0.14s ease;
  will-change: left, top;
}

.tianma-puzzle-piece:focus {
  outline: none;
}

.tianma-puzzle-piece:focus-visible {
  outline: 2px solid rgba(232, 200, 120, 0.95);
  outline-offset: 3px;
  border-radius: 4px;
}

.tianma-puzzle-piece.is-dragging {
  cursor: grabbing;
  opacity: 0.9;
  z-index: 50;
  transition: opacity 0.15s ease;
}

.tianma-puzzle-piece.is-dragging .tianma-puzzle-piece-img {
  filter: drop-shadow(1px 0 0 rgba(45, 42, 38, 0.95)) drop-shadow(-1px 0 0 rgba(45, 42, 38, 0.95))
    drop-shadow(0 1px 0 rgba(45, 42, 38, 0.95)) drop-shadow(0 -1px 0 rgba(45, 42, 38, 0.95))
    drop-shadow(0 8px 18px rgba(0, 0, 0, 0.38));
}

.tianma-puzzle-piece.is-locked {
  cursor: default;
  pointer-events: none;
  opacity: 1;
  z-index: 3;
  box-shadow: none;
}

.tianma-puzzle-piece-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.tianma-puzzle-piece-img {
  display: block;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  object-fit: contain;
  vertical-align: middle;
  filter: drop-shadow(1px 0 0 rgba(45, 42, 38, 0.95)) drop-shadow(-1px 0 0 rgba(45, 42, 38, 0.95))
    drop-shadow(0 1px 0 rgba(45, 42, 38, 0.95)) drop-shadow(0 -1px 0 rgba(45, 42, 38, 0.95))
    drop-shadow(0 3px 8px rgba(0, 0, 0, 0.22));
  pointer-events: none;
}

.tianma-puzzle-footer-actions {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.tianma-puzzle-reset-footer,
.tianma-puzzle-learn-footer {
  align-self: center;
  min-width: 180px;
  padding: 11px 32px;
  border-radius: 999px;
  border: 1px solid rgba(212, 175, 95, 0.65);
  background: linear-gradient(180deg, #6a4a38 0%, #3d2a20 100%);
  color: #f0d78c;
  font-size: 17px;
  font-family: "STKaiti", "KaiTi", "Songti SC", serif;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.32);
  transition: filter 0.15s ease, transform 0.12s ease;
}

.tianma-puzzle-reset-footer:hover,
.tianma-puzzle-learn-footer:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.tianma-puzzle-learn-footer {
  background: linear-gradient(180deg, #4f5f3b 0%, #2f3c24 100%);
  border-color: rgba(197, 215, 124, 0.75);
  color: #e9f2be;
}

.tianma-puzzle-learn-footer.is-active {
  background: linear-gradient(180deg, #7f9f4c 0%, #47602e 100%);
  border-color: rgba(235, 248, 176, 0.92);
  color: #fff8dc;
  box-shadow: 0 10px 22px rgba(66, 102, 40, 0.48);
}

.tianma-puzzle-toast {
  position: fixed;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%) scale(0.92);
  z-index: 200;
  padding: 20px 32px;
  border-radius: 18px;
  border: 1px solid rgba(255, 220, 120, 0.55);
  background: linear-gradient(180deg, rgba(72, 118, 92, 0.98), rgba(42, 78, 58, 0.99));
  color: #fff8e8;
  font-size: 22px;
  font-weight: 700;
  font-family: "STKaiti", "KaiTi", "Songti SC", serif;
  letter-spacing: 0.08em;
  text-align: center;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.48);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.tianma-puzzle-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

@media (max-width: 640px) {
  .tianma-puzzle-shell {
    min-height: unset;
    max-height: 94vh;
  }

  .tianma-puzzle-stage {
    flex-direction: column;
    min-height: unset;
  }

  .tianma-puzzle-tray {
    flex: 0 0 auto;
    min-height: 140px;
    border-right: none;
    border-bottom: 2px solid rgba(35, 48, 42, 0.45);
  }

  .tianma-puzzle-mount {
    min-height: 320px;
  }

  .tianma-puzzle-silhouette {
    max-height: min(42vh, 380px);
  }
}
