/* ============================================================================
   点灯 Lights Out · 游戏专属样式
   选择器统一以 .g-lightson 前缀限定，避免影响其他游戏
   ========================================================================== */

.g-lightson {
  --ls-on: #ffd166;
  --ls-on-2: #ffb020;
  gap: 10px;
  padding: 12px 10px calc(14px + var(--safe-b));
}

.g-lightson .stats .stat-v { font-size: 17px; }

.g-lightson .ls-ctrl { gap: 8px; align-items: stretch; }
.g-lightson .ls-ctrl .seg { flex: 1; min-width: 0; }
.g-lightson .ls-ctrl .badge { flex: none; align-self: center; min-height: 26px; padding: 4px 10px; }

.g-lightson .ls-board-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 0;
}

.g-lightson .ls-board {
  --cell: 52px;
  --gap: 8px;
  --pad: 10px;
  display: grid;
  gap: var(--gap);
  padding: var(--pad);
  margin: auto;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.018));
  box-shadow: 0 26px 56px -30px rgba(0, 0, 0, 0.92), inset 0 1px 0 rgba(255, 255, 255, 0.055);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  touch-action: manipulation;
}
.g-lightson .ls-board.won {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: 0 0 40px rgba(255, 209, 102, 0.26), 0 26px 56px -30px rgba(0, 0, 0, 0.92),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

/* ------------------------------ 灯 ------------------------------ */

.g-lightson .ls-cell {
  position: relative;
  width: var(--cell);
  height: var(--cell);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: calc(var(--cell) * 0.26);
  border: 1px solid rgba(255, 255, 255, 0.075);
  background: radial-gradient(circle at 50% 30%, #2b3242, #171b25 72%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), inset 0 -6px 12px rgba(0, 0, 0, 0.35);
  transition: background 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.g-lightson .ls-cell::after {
  content: "";
  width: 46%;
  height: 46%;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 32%, #59637a, #2c3444 78%);
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.5);
  transition: background 0.14s ease, box-shadow 0.14s ease, transform 0.14s ease;
}
.g-lightson .ls-cell.on {
  background: radial-gradient(circle at 50% 28%, #fff6cf 0%, #ffd166 52%, #e0960a 100%);
  border-color: rgba(255, 224, 138, 0.9);
  box-shadow: 0 0 20px rgba(255, 209, 102, 0.5), 0 0 46px rgba(255, 209, 102, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
}
.g-lightson .ls-cell.on::after {
  background: radial-gradient(circle at 40% 32%, #fffef2, #ffe27a 74%);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.85), inset 0 0 6px rgba(255, 255, 255, 0.6);
}
.g-lightson .ls-cell:active { filter: brightness(0.94); }

/* 提示：最优解第一盏灯 */
.g-lightson .ls-cell.hint {
  border-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.82), 0 0 22px rgba(255, 255, 255, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  z-index: 2;
}
@media (prefers-reduced-motion: no-preference) {
  .g-lightson .ls-cell.hint { animation: ls-hint 0.95s ease-in-out infinite; }
}
@keyframes ls-hint {
  0%, 100% { box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.85), 0 0 22px rgba(255, 255, 255, 0.55); }
  50% { box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.35), 0 0 30px rgba(255, 255, 255, 0.3); }
}

/* 通关后的呼吸光 */
@media (prefers-reduced-motion: no-preference) {
  .g-lightson .ls-board.won { animation: ls-win-glow 1.8s ease-in-out infinite alternate; }
}
@keyframes ls-win-glow {
  from { box-shadow: 0 0 26px rgba(255, 209, 102, 0.16), 0 26px 56px -30px rgba(0, 0, 0, 0.92); }
  to { box-shadow: 0 0 52px rgba(255, 209, 102, 0.34), 0 26px 56px -30px rgba(0, 0, 0, 0.92); }
}

/* 完成后收起统计与尺寸切换，把空间让给棋盘 */
.g-lightson.won-view .stats,
.g-lightson.won-view .ls-ctrl { display: none; }
.g-lightson.won-view .ls-board-wrap {
  justify-content: flex-start;
  padding-top: 4px;
  overflow: visible;
}
.g-lightson.won-view .ls-board {
  margin: 0 auto;
  transform: scale(0.86);
  transform-origin: top center;
  transition: transform 0.3s ease;
}

/* ------------------------------ 结算弹窗 ------------------------------ */

.overlay.ls-result-overlay {
  align-items: flex-end;
  padding: 14px 16px calc(18px + var(--safe-b));
  background: rgba(4, 6, 11, 0.4);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.overlay.ls-result-overlay .dialog { padding: 15px 16px; border-radius: 18px; }
.overlay.ls-result-overlay .dialog-actions { margin-top: 13px; }

.ls-res-star {
  font-size: 34px;
  line-height: 1.15;
  text-align: center;
  margin: 2px 0 2px;
  filter: drop-shadow(0 0 14px rgba(255, 209, 102, 0.55));
}
.ls-res-k {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 11px;
}
.ls-res-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  text-align: center;
}
.ls-res-grid b {
  display: block;
  font-size: 15.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  color: var(--text);
}
.ls-res-grid .hint { display: block; font-size: 10px; }
.ls-res-tip {
  margin-top: 11px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--warn);
}

/* 小屏压缩 */
@media (max-width: 374px) {
  .g-lightson { padding-left: 8px; padding-right: 8px; gap: 8px; }
  .g-lightson .g-head-right .btn { padding: 6px 8px; }
  .g-lightson .ls-ctrl .badge { display: none; }
}
