/* ==============================================================
   七巧板 · 游戏专属样式
   选择器统一以 .g-tangram 前缀限定
   ============================================================== */

.g-tangram {
  --tg-ink: #06100d;
  gap: 10px;
}

/* ------------------------------ 顶部数据 ------------------------------ */

.g-tangram .tg-hud {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  flex: none;
}
.g-tangram .tg-hud-i {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 5px;
  min-height: 32px;
  padding: 5px 4px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.g-tangram .tg-k {
  font-size: 10px;
  color: var(--faint);
  letter-spacing: 0.04em;
}
.g-tangram .tg-v {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

/* ------------------------------ 棋盘 ------------------------------ */

.g-tangram .tg-board-wrap {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.g-tangram .tg-board {
  position: relative;
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: 0 22px 60px -30px rgba(0, 0, 0, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  overflow: hidden;
  background: #080e12;
}

.g-tangram .tg-svg {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

/* 扫描网格 / 托盘 / 剪影 */
.g-tangram .tg-tray {
  fill: rgba(255, 255, 255, 0.022);
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 0.02;
  stroke-dasharray: 0.12 0.1;
}
.g-tangram .tg-sil {
  fill: rgba(3, 9, 7, 0.94);
  stroke: var(--accent);
  stroke-width: 0.048;
  stroke-dasharray: 0.17 0.12;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 0.12px color-mix(in srgb, var(--accent) 55%, transparent));
}
.g-tangram .tg-hint {
  fill: color-mix(in srgb, var(--accent) 28%, transparent);
  stroke: var(--accent);
  stroke-width: 0.05;
  stroke-dasharray: 0.13 0.09;
  stroke-linejoin: round;
  pointer-events: none;
  animation: tgPulse 1s ease-in-out infinite;
}

/* 棋子 */
.g-tangram .tg-piece {
  cursor: grab;
  filter: drop-shadow(0 0.055px 0.05px rgba(0, 0, 0, 0.5));
}
.g-tangram .tg-piece polygon {
  stroke: rgba(4, 10, 8, 0.55);
  stroke-width: 0.028;
  stroke-linejoin: round;
  transition: stroke 0.15s;
}
.g-tangram .tg-piece.sel { filter: drop-shadow(0 0 0.14px rgba(255, 255, 255, 0.55)); cursor: grabbing; }
.g-tangram .tg-piece.sel polygon { stroke: rgba(255, 255, 255, 0.92); stroke-width: 0.042; }
.g-tangram .tg-piece.placed { cursor: default; }
.g-tangram .tg-piece.just polygon { animation: tgFlash 0.15s ease-out; }
.g-tangram .tg-piece.placed { filter: drop-shadow(0 0 0.08px color-mix(in srgb, var(--ok) 40%, transparent)); }

/* ------------------------------ 底部操作 ------------------------------ */

.g-tangram .tg-ctrl {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  flex: none;
}
.g-tangram .tg-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 46px;
  padding: 0 6px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--dim);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: transform 0.08s, background 0.15s, border-color 0.15s, color 0.15s;
  touch-action: manipulation;
}
.g-tangram .tg-btn:active { transform: scale(0.96); background: var(--surface-2); border-color: var(--line-2); }
.g-tangram .tg-btn-i { display: inline-flex; width: 18px; height: 18px; flex: none; }
.g-tangram .tg-btn-i svg { width: 18px; height: 18px; }

/* ------------------------------ 选关 ------------------------------ */

.g-tangram .tg-levels {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  flex: none;
}
.g-tangram .tg-level {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 86px;
  padding: 8px 4px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  transition: transform 0.1s, background 0.15s, border-color 0.15s;
  touch-action: manipulation;
}
.g-tangram .tg-level:active { transform: scale(0.97); }
.g-tangram .tg-level.done {
  border-color: color-mix(in srgb, var(--accent) 42%, transparent);
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 12%, transparent), rgba(255, 255, 255, 0.02));
}
.g-tangram .tg-level.locked { opacity: 0.42; }
.g-tangram .tg-lv-n {
  font-size: 21px;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.g-tangram .tg-level.done .tg-lv-n { color: var(--accent); }
.g-tangram .tg-lv-name { font-size: 11px; color: var(--dim); }
.g-tangram .tg-lv-sub { font-size: 9.5px; color: var(--faint); text-align: center; line-height: 1.2; }
.g-tangram .tg-lv-done { color: var(--ok); }
.g-tangram .tg-tip {
  margin-top: auto;
  padding-top: 6px;
  text-align: center;
  font-size: 11px;
}

/* ------------------------------ 动画 ------------------------------ */

@keyframes tgFlash {
  0% { stroke: #ffffff; stroke-width: 0.1; }
  45% { stroke: #b9ffe9; stroke-width: 0.09; }
  100% { stroke: rgba(4, 10, 8, 0.55); stroke-width: 0.028; }
}
@keyframes tgPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ------------------------------ 适配 ------------------------------ */

@media (max-height: 710px) {
  .g-tangram { gap: 8px; }
  .g-tangram .tg-btn { min-height: 42px; }
  .g-tangram .tg-level { min-height: 74px; }
  .g-tangram .tg-hud-i { min-height: 28px; }
  .g-tangram .tg-tip { display: none; }
}

@media (max-width: 365px) {
  .g-tangram { gap: 8px; }
  .g-tangram .tg-btn { font-size: 12px; }
  .g-tangram .tg-levels { gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .g-tangram .tg-hint,
  .g-tangram .tg-piece.just polygon { animation: none; }
}

/* 头部小按钮热区 ≥40px */
.g-tangram .btn.sm { min-height: 40px; }
