/* 拼块填满 Polyomino · 独立样式（选择器统一前缀 .g-poly） */

.g-poly {
  justify-content: flex-start;
  gap: 8px;
}

/* ---------------- 顶部 ---------------- */

.g-poly .poly-head { min-height: 40px; }
.g-poly .poly-head .g-title { font-size: 14px; }
.g-poly .poly-head .g-head-right { flex: none; }

/* ---------------- 数据 ---------------- */

.g-poly .stats { gap: 8px; }
.g-poly .stat { padding: 5px 6px; }
.g-poly .stat-v { font-size: 16px; }

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

.g-poly .poly-boardwrap {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.g-poly .poly-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--n, 5), minmax(0, 1fr));
  grid-template-rows: repeat(var(--n, 5), minmax(0, 1fr));
  gap: 2px;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  padding: 0;
  border-radius: 18px;
  overflow: hidden;
  background:
    radial-gradient(120% 120% at 100% 0%, rgba(95, 224, 200, 0.09), transparent 58%),
    linear-gradient(160deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.018));
  border: 1px solid var(--line-2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 22px 54px -32px rgba(0, 0, 0, 0.95);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.g-poly .poly-board[data-n="5"] { width: min(100%, 300px); }
.g-poly .poly-board[data-n="6"] { width: min(100%, 318px); }
.g-poly .poly-board[data-n="7"] { width: min(100%, 330px); }

.g-poly .poly-cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.03);
  transition: background 0.14s ease, box-shadow 0.14s ease;
}

.g-poly .poly-cell:nth-child(even) { background: rgba(255, 255, 255, 0.045); }

.g-poly .poly-cell.filled {
  background: var(--pc, #5fe0c8);
  background-image: linear-gradient(160deg, rgba(255, 255, 255, 0.28), rgba(0, 0, 0, 0.16));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), inset 0 -6px 12px rgba(0, 0, 0, 0.14);
}

.g-poly .poly-cell.hl-ok {
  box-shadow: inset 0 0 0 2px var(--accent), 0 0 12px rgba(95, 224, 200, 0.45);
  background: rgba(95, 224, 200, 0.14);
}

.g-poly .poly-cell.hl-bad {
  box-shadow: inset 0 0 0 2px var(--err);
  background: rgba(255, 92, 108, 0.16);
}

.g-poly .poly-cell.hint {
  animation: polyHint 0.6s ease;
}

@keyframes polyHint {
  0% { box-shadow: inset 0 0 0 3px var(--accent), 0 0 0 rgba(95, 224, 200, 0); }
  55% { box-shadow: inset 0 0 0 3px var(--accent), 0 0 18px rgba(95, 224, 200, 0.8); }
  100% { box-shadow: inset 0 0 0 0 var(--accent), 0 0 0 rgba(95, 224, 200, 0); }
}

/* ---------------- 托盘 ---------------- */

.g-poly .poly-traywrap {
  flex: 0 0 auto;
  padding: 7px 8px 8px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.g-poly .poly-tray-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}

.g-poly .poly-tray-k {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--dim);
}

.g-poly .poly-tray-hint { font-size: 10px; }

.g-poly .poly-tray {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 6px;
  min-height: 40px;
}

.g-poly .poly-tray-empty {
  font-size: 11.5px;
  color: var(--faint);
  padding: 12px 4px;
}

.g-poly .poly-piece {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  padding: 4px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.g-poly .poly-piece.in-tray:active { background: rgba(255, 255, 255, 0.1); }

.g-poly .poly-shape {
  display: grid;
  gap: 2px;
}

.g-poly .poly-pcell {
  border-radius: 5px;
  background: var(--pc, #5fe0c8);
  background-image: linear-gradient(160deg, rgba(255, 255, 255, 0.26), rgba(0, 0, 0, 0.14));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), inset 0 -3px 6px rgba(0, 0, 0, 0.12);
}

/* 拖动中的浮层 */
.g-poly .poly-clone {
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.55));
  transform-origin: center;
  transition: none;
  will-change: left, top;
}

.g-poly .poly-clone .poly-shape { gap: 2px; }
.g-poly .poly-clone .poly-pcell { border-radius: 5px; }

/* ---------------- 操作行 ---------------- */

.g-poly .poly-toolbar .btn { min-height: 42px; }
.g-poly .poly-toolbar .btn.is-disabled {
  opacity: 0.42;
  pointer-events: none;
}

/* ---------------- 底部信息 ---------------- */

.g-poly .poly-meta { padding: 7px 12px 8px; }
.g-poly .poly-meta-head { align-items: baseline; gap: 8px; }
.g-poly .poly-meta-head .hint:first-child {
  color: var(--dim);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.g-poly .poly-meta-head .hint:last-child { flex: none; color: var(--dim); font-variant-numeric: tabular-nums; }
.g-poly .poly-tip {
  margin-top: 6px;
  font-size: 10.5px;
  line-height: 1.55;
  color: var(--faint);
}

/* ---------------- 通关覆盖层 ---------------- */

.g-poly .poly-win {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(8, 11, 18, 0.85);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s;
}

.g-poly .poly-win.show { opacity: 1; visibility: visible; }

.g-poly .poly-win-card {
  width: 100%;
  max-width: 254px;
  text-align: center;
}

.g-poly .poly-win-title {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.35;
}

.g-poly .poly-win-sub {
  margin-top: 5px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--dim);
}

.g-poly .poly-win-stats {
  display: flex;
  gap: 8px;
  margin: 13px 0;
}

.g-poly .poly-wstat {
  flex: 1;
  min-width: 0;
  padding: 7px 4px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
}

.g-poly .poly-wstat span {
  display: block;
  font-size: 10px;
  color: var(--faint);
  margin-bottom: 2px;
}

.g-poly .poly-wstat b {
  display: block;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.g-poly .poly-win .btn { min-height: 44px; }
.g-poly .poly-win .btn-row { gap: 8px; }
.g-poly .poly-win-row2 { margin-top: 8px; }
.g-poly .poly-win-row2 .btn { min-height: 36px; font-size: 12.5px; }

/* ---------------- 选关弹层（复用 app.css 的 .overlay/.dialog） ---------------- */

.poly-level-card { max-width: 360px; }

.poly-level-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.poly-lv {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 58px;
  padding: 7px 4px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
}

.poly-lv .poly-lv-n { font-size: 15px; font-weight: 800; line-height: 1.1; }
.poly-lv .poly-lv-s { font-size: 10px; color: var(--dim); }
.poly-lv .poly-lv-t { font-size: 9.5px; color: var(--faint); font-variant-numeric: tabular-nums; }

.poly-lv.done {
  border-color: rgba(95, 224, 200, 0.4);
  background: rgba(95, 224, 200, 0.09);
}
.poly-lv.done .poly-lv-t { color: var(--accent); }

.poly-lv.current {
  box-shadow: 0 0 0 1.5px var(--accent);
}

.poly-lv.locked {
  opacity: 0.45;
  background: rgba(255, 255, 255, 0.03);
}

.poly-level-foot { margin-top: 14px; }

/* ---------------- 窄屏 / 动效偏好 ---------------- */

@media (max-width: 359px) {
  .g-poly .poly-head .g-title { font-size: 13px; }
  .g-poly .poly-tray { gap: 6px; }
  .g-poly .poly-traywrap { padding: 8px; }
  .g-poly .stat-v { font-size: 15.5px; }
}

@media (prefers-reduced-motion: reduce) {
  .g-poly .poly-cell.hint { animation: none; box-shadow: inset 0 0 0 2px var(--accent); }
}
