/* 练习场独立页：整页固定、不滚动；上方魔方，下方九宫格 */
html.pp-html, .pp-html body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body.pp-body {
  position: fixed; inset: 0; margin: 0;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.pp {
  height: 100%; height: 100dvh; max-width: 560px; margin: 0 auto;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.pp svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.pp svg .fill { fill: currentColor; stroke: none; }

/* 顶栏 */
.pp-bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 8px 10px 0; }
.pp-back { display: inline-flex; align-items: center; gap: 2px; text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: 15px; padding: 8px 6px; justify-self: start; }
.pp-status {
  font: 700 15px/1 var(--mono); padding: 8px 14px; border-radius: 99px;
  background: var(--card); border: 1px solid var(--line); min-width: 92px; text-align: center; transition: color .2s;
}
.pp-status.ok { color: var(--ok); }
.pp-tools { display: flex; gap: 4px; justify-self: end; }
.pp-tool { width: 42px; height: 42px; border-radius: 12px; border: 0; background: none; color: var(--ink); display: grid; place-items: center; cursor: pointer; }
.pp-tool:active { background: var(--bg-alt); }

/* 魔方区：整个区域都是手势面 */
.pp-stage { position: relative; min-height: 0; }
.pp-cube { position: absolute; inset: 0; cursor: default; }
.pp-cube.cv { cursor: grab; }
.pp-stage.touching .pp-cube { cursor: grabbing; }
.pp-hint {
  position: absolute; top: 8px; left: 16px; right: 16px; margin: 0; text-align: center;
  font-size: 13px; color: var(--ink-3); pointer-events: none; transition: opacity .4s;
}
.pp-hint.gone { opacity: 0; }
.pp-history {
  position: absolute; left: 12px; right: 12px; bottom: 6px; display: flex; justify-content: center; gap: 6px;
  font: 600 14px/1.6 var(--mono); color: var(--ink-3); pointer-events: none; white-space: nowrap; overflow: hidden;
}
.pp-history span:last-child { color: var(--accent); }

/* 九宫格 */
.pp-pad { padding: 6px 12px 12px; }
.pp-padbar { display: flex; gap: 8px; margin-bottom: 8px; }
.pp-scramble {
  flex: none; border: 0; border-radius: 10px; padding: 0 16px; background: var(--accent); color: var(--accent-ink);
  font: 700 15px/1 var(--sans); cursor: pointer;
}
.pp-scramble:active { filter: brightness(.92); }
.pp-mode { flex: 1; display: grid; grid-template-columns: 1fr 1fr; background: var(--bg-alt); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.pp-mode button { border: 0; background: none; color: var(--ink-2); font: 600 14px/1 var(--sans); padding: 10px 6px; border-radius: 7px; cursor: pointer; }
.pp-mode button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.pp-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; padding: 7px; background: var(--plastic); border-radius: 16px; }
.pp-key {
  position: relative; height: clamp(54px, 9.6dvh, 84px); border: 0; border-radius: 10px; padding: 0; cursor: pointer;
  background: var(--c-F); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .2); transition: background .2s;
}
.pp-keys[data-layer="row"] .pp-key { background: var(--c-B); }
.pp-key:focus-visible { outline: 3px solid var(--c-U); outline-offset: 1px; }
.pp-key.hit { animation: pp-hit .2s ease-out; }
@keyframes pp-hit { 0% { transform: scale(.9); filter: brightness(1.4); } 100% { transform: none; filter: none; } }
.pp-key-kb { position: absolute; top: 5px; left: 7px; font: 700 11px/1 var(--mono); opacity: .8; }
.pp-key-kb i { font-style: normal; opacity: .7; margin-left: 3px; }
.pp-key-arrow { font-size: clamp(20px, 3.4dvh, 28px); line-height: 1; }
.pp-key-move { font: 700 14px/1.2 var(--mono); }
@media (hover: none) { .pp-key-kb { display: none; } }

/* 底部弹出面板 */
.pp-sheet { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0); display: flex; align-items: flex-end; justify-content: center; transition: background .18s; touch-action: auto; }
.pp-sheet[hidden] { display: none; }
.pp-sheet.open { background: rgba(0, 0, 0, .38); }
.pp-sheet-panel {
  width: 100%; max-width: 560px; max-height: 86dvh; overflow-y: auto; background: var(--card); border-radius: 18px 18px 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform .18s ease-out;
  user-select: text; -webkit-user-select: text; touch-action: pan-y;
}
.pp-sheet.open .pp-sheet-panel { transform: none; }
.pp-sheet-panel h2 { font-size: 18px; margin-bottom: 14px; }
.pp-alg label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.pp-alg-row { display: flex; gap: 8px; }
.pp-alg input { flex: 1; min-width: 0; font: 500 16px/1 var(--mono); padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
.pp-sheet-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0 16px; }
.pp-sheet-btns .btn { justify-content: center; }
.pp-help p { font-size: 14px; color: var(--ink-2); margin-bottom: 8px; }
.pp-sheet-close { width: 100%; justify-content: center; margin-top: 4px; }

/* 横屏手机：左魔方、右九宫格 */
@media (orientation: landscape) and (max-height: 560px) {
  .pp { max-width: none; grid-template-columns: minmax(0, 1fr) min(44vw, 340px); grid-template-rows: auto minmax(0, 1fr); }
  .pp-bar { grid-column: 1 / -1; padding-top: 4px; }
  .pp-pad { align-self: center; padding-top: 0; }
  .pp-key { height: clamp(40px, 15dvh, 68px); }
}
/* 宽屏桌面：九宫格适当收窄 */
@media (min-width: 700px) and (min-height: 700px) {
  .pp-pad { padding-bottom: 24px; }
}
