/* ==============================================================
   数字金字塔 · 游戏专属样式
   选择器统一以 .g-pyramid / .py-* 前缀限定
   ============================================================== */

.g-pyramid {
  --py-line: rgba(255, 255, 255, 0.08);
  gap: 10px;
}

/* ------------------------------ 顶部状态 ------------------------------ */

.py-hud {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
}
.py-hud .badge { font-size: 11px; padding: 4px 10px; }
.py-qidx {
  font-size: 12px;
  font-weight: 700;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.py-hints {
  font-size: 11px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.py-time {
  margin-left: auto;
  font-size: 19px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

/* ------------------------------ 金字塔 ------------------------------ */

.py-board-holder {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.py-board {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  touch-action: manipulation;
}
.py-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
}
.py-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  padding: 0;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.025));
  color: #fff8f0;
  overflow: hidden;
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.py-cell:active { transform: scale(0.96); }
.py-n4 .py-cell { width: 56px; height: 56px; }
.py-n5 .py-cell { width: 50px; height: 50px; }
.py-n6 .py-cell { width: 44px; height: 44px; }
.py-cell.given {
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.085), rgba(255, 255, 255, 0.03));
  border-color: rgba(255, 255, 255, 0.12);
}
.py-cell.blank {
  border-style: dashed;
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
  background: color-mix(in srgb, var(--accent) 7%, rgba(255, 255, 255, 0.02));
}
.py-cell.blank.filled {
  border-style: solid;
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background: color-mix(in srgb, var(--accent) 14%, rgba(255, 255, 255, 0.02));
}
.py-cell.sel {
  z-index: 2;
  border-style: solid;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 50%, transparent), 0 0 18px color-mix(in srgb, var(--accent) 30%, transparent);
  transform: scale(0.97);
}
.py-cell.bad {
  border-style: solid;
  border-color: #ff7684;
  background: rgba(255, 95, 110, 0.16);
  box-shadow: 0 0 0 2px rgba(255, 95, 110, 0.5);
}
.py-cell.blank.filled.bad {
  border-color: #ff5c6c;
  background: rgba(255, 95, 110, 0.24);
  box-shadow: 0 0 0 2.5px rgba(255, 92, 108, 0.65), 0 0 18px rgba(255, 92, 108, 0.22);
}
.py-cell.blank.filled.bad .py-v { color: #ffd0d5; }
.py-cell.sel.bad { border-color: #ff5c6c; box-shadow: 0 0 0 2.5px #ff5c6c; }
.py-v {
  font-family: var(--mono);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  letter-spacing: -0.03em;
}
.py-n4 .py-v { font-size: 25px; }
.py-n5 .py-v { font-size: 22px; }
.py-n6 .py-v { font-size: 20px; }
.py-cell.len3 .py-v { font-size: 17px; }
.py-n5 .py-cell.len3 .py-v { font-size: 16px; }
.py-n6 .py-cell.len3 .py-v { font-size: 15px; }
.py-cell.len4 .py-v { font-size: 14px; }
.py-n5 .py-cell.len4 .py-v { font-size: 13px; }
.py-n6 .py-cell.len4 .py-v { font-size: 12px; }
.py-cell.blank:not(.filled) .py-v { color: transparent; }
.py-cell.blank:not(.filled)::after {
  content: '?';
  position: absolute;
  font-size: 12px;
  color: color-mix(in srgb, var(--accent) 72%, transparent);
  opacity: 0.55;
  pointer-events: none;
}
.py-cell.bad.blank:not(.filled)::after { color: #ffb0b8; }

/* ------------------------------ 工具 / 键盘 ------------------------------ */

.py-tools {
  flex: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.py-tools .btn {
  min-height: 42px;
  gap: 7px;
  font-size: 13px;
}
.py-tool-i { display: inline-flex; width: 17px; height: 17px; }
.py-tool-i svg { width: 17px; height: 17px; }
.py-tools .py-tool[data-act="hint"] {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 32%, var(--line));
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}

.py-pad {
  flex: none;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}
.py-pad .pad-key {
  min-height: 46px;
  font-size: 20px;
  font-weight: 700;
  padding: 0;
}
.py-pad .py-back,
.py-pad .py-clear {
  font-size: 12.5px;
  font-weight: 600;
}
.py-pad .py-back { color: var(--dim); }
.py-pad .py-clear { color: #ff9aa4; }
.py-tip {
  flex: none;
  min-height: 17px;
  text-align: center;
  font-size: 10.5px;
  color: var(--faint);
}

/* ------------------------------ 开始页 ------------------------------ */

.py-start { gap: 12px; }
.py-startp { display: flex; flex-direction: column; }
.py-start .seg-item { min-height: 42px; font-size: 13px; }
.py-desc {
  margin-top: 9px;
  font-size: 11.5px;
  color: var(--faint);
}
.py-bestinfo { display: flex; flex-direction: column; margin-top: 2px; }
.py-brow {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 6px 2px;
  border-bottom: 1px solid var(--line);
}
.py-brow:last-child { border-bottom: 0; }
.py-brow .n { font-size: 12.5px; color: var(--dim); }
.py-brow .b { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.py-start-btn { margin-top: 14px; min-height: 48px; }
.py-foot.hint { margin-top: auto; padding-top: 8px; text-align: center; font-size: 11px; }

/* ------------------------------ 结算 ------------------------------ */

.py-resultwrap { gap: 12px; }
.py-result {
  flex: none;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--ok) 30%, var(--line));
  background: linear-gradient(165deg,
      color-mix(in srgb, var(--ok) 10%, transparent),
      rgba(255, 255, 255, 0.02));
  padding: 14px var(--pad) 15px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: pyUp 0.32s cubic-bezier(0.22, 0.9, 0.3, 1) both;
}
.py-result-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.py-result-k {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--dim);
  letter-spacing: 0.04em;
}
.py-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
  flex: none;
}
.py-result-time {
  margin-top: 2px;
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.06;
}
.py-result-meta {
  text-align: right;
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.py-best { color: var(--dim); }
.py-best.new { color: var(--ok); font-weight: 700; }
.py-result .btn-row .btn { min-height: 44px; }
.py-result-sub { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.py-result-sub .btn { min-height: 38px; }

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

@keyframes pyUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------ 矮屏 / 小屏 ------------------------------ */

@media (max-height: 710px) {
  .g-pyramid { gap: 8px; }
  .py-hud { min-height: 26px; }
  .py-board { gap: 4px; }
  .py-row { gap: 4px; }
  .py-n4 .py-cell { width: 52px; height: 52px; }
  .py-n5 .py-cell { width: 47px; height: 47px; }
  .py-n6 .py-cell { width: 42px; height: 42px; }
  .py-n4 .py-v { font-size: 23px; }
  .py-n5 .py-v { font-size: 21px; }
  .py-n6 .py-v { font-size: 19px; }
  .py-tools .btn { min-height: 40px; }
  .py-pad .pad-key { min-height: 43px; }
  .py-start { gap: 10px; }
  .py-startp { padding: 12px; }
  .py-start-btn { margin-top: 10px; }
  .py-foot.hint { display: none; }
  .py-result { padding: 12px var(--pad) 13px; gap: 10px; }
  .py-result-time { font-size: 32px; }
}

@media (max-width: 365px) {
  .g-pyramid { gap: 8px; }
  .py-board { gap: 4px; }
  .py-row { gap: 4px; }
  .py-pad { gap: 5px; }
  .py-pad .pad-key { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .py-result { animation: none; }
  .py-cell { transition: none; }
}
