:root {
  --bg: #0b1426;
  --panel: #13213b;
  --ink: #e8eef8;
  --muted: #8ea1c0;
  --warm: #ffcf6b;
  --btn: #1e3358;
  --btn-hi: #2a4675;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font-family: "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", system-ui, sans-serif; }
body { overscroll-behavior: none; }
#app { max-width: 520px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column;
  padding: max(8px, env(safe-area-inset-top)) 12px max(10px, env(safe-area-inset-bottom)); gap: 8px; }
.top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
h1 { margin: 0; font-size: 22px; letter-spacing: 4px; color: var(--warm); }
.info { display: flex; gap: 10px; font-size: 14px; color: var(--muted); }
.lamps { color: var(--warm); }
#board-wrap { position: relative; touch-action: none; user-select: none; -webkit-user-select: none; flex: 1 1 auto; min-height: 240px; display: flex; align-items: center; justify-content: center; }
#board { display: block; touch-action: none; image-rendering: pixelated; border-radius: 6px; }
.banner { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(11, 20, 38, 0.92);
  border: 2px solid var(--warm); border-radius: 10px; padding: 14px 18px; text-align: center; min-width: 220px; }
.banner p { margin: 0 0 10px; font-size: 18px; }
.banner-actions { display: flex; gap: 8px; justify-content: center; }
.tip { margin: 0; min-height: 1.4em; text-align: center; font-size: 13px; color: var(--muted); }
.actions { display: flex; gap: 8px; }
.actions button { flex: 1; }
button { min-height: 44px; border: 0; border-radius: 8px; background: var(--btn); color: var(--ink); font-size: 16px; cursor: pointer;
  font-family: inherit; padding: 0 14px; }
button:hover:not(:disabled) { background: var(--btn-hi); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.primary { background: var(--warm); color: #2a1c00; font-weight: bold; }
button.ghost { background: transparent; color: var(--muted); }
button.pulse { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px rgba(255, 207, 107, 0.45); } }
.modal { position: fixed; inset: 0; background: rgba(3, 7, 15, 0.7); display: flex; align-items: center; justify-content: center; z-index: 10; }
.modal[hidden], .banner[hidden], [hidden] { display: none !important; }
.sheet { background: var(--panel); border-radius: 12px; padding: 18px; width: min(320px, 90vw); display: flex; flex-direction: column; gap: 10px; text-align: center; }
.sheet.wide { width: min(420px, 94vw); }
.sheet h2 { margin: 0; font-size: 20px; color: var(--warm); }
.muted { color: var(--muted); font-size: 13px; margin: 0; }
.ad .sheet { border: 2px dashed var(--muted); }
.ad-tag { margin: 0; font-size: 12px; color: var(--muted); }
.ad-title { margin: 0; font-size: 18px; }
.ad-count { margin: 0; font-size: 48px; color: var(--warm); font-weight: bold; }
.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 6px; }
.level-grid button { padding: 0; font-size: 15px; }
.level-grid button { position: relative; }
.level-grid button.solved { background: #2d4a2f; }
.level-grid button.par { background: #3d3a1c; box-shadow: inset 0 0 0 2px var(--warm); }
.par-badge, .legend .key.par { background: var(--warm); color: #2a1c00; font-size: 10px;
  line-height: 14px; padding: 0 3px; border-radius: 4px; font-weight: bold; }
.par-badge { position: absolute; top: -6px; right: 2px; }
.nohint-badge, .legend .key.nohint { background: #8fd3a8; color: #0f2a19; font-size: 10px;
  line-height: 14px; padding: 0 3px; border-radius: 4px; font-weight: bold; }
.nohint-badge { position: absolute; top: -6px; left: 2px; }
.legend { display: flex; align-items: center; justify-content: center; gap: 4px; flex-wrap: wrap; }
.legend .key { display: inline-block; }
.legend .key.solved { width: 14px; height: 14px; border-radius: 3px; background: #2d4a2f; }
.banner-steps { font-size: 15px !important; color: var(--warm); white-space: nowrap; }
.banner-steps.over { color: var(--ink); }
.level-grid button.current { outline: 2px solid var(--warm); }
/* 轻扫引导：一只「手指」从玩家处按下、沿方向划出一道拖痕后抬起，循环播放。纯展示，不接收任何点击。 */
.swipe-guide { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.guide-track { position: absolute; width: 0; height: 0; }
.guide-finger { position: absolute; left: -15px; top: -15px; width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.9); box-shadow: 0 0 0 4px rgba(255, 207, 107, 0.55), 0 2px 8px rgba(0, 0, 0, 0.45);
  animation: guide-finger 1.6s ease-in-out infinite; }
.guide-trail { position: absolute; left: 0; top: -4px; height: 8px; width: var(--len, 90px); border-radius: 4px; transform-origin: 0 50%;
  background: linear-gradient(90deg, rgba(255, 207, 107, 0), rgba(255, 207, 107, 0.85)); animation: guide-trail 1.6s ease-in-out infinite; }
.guide-track[data-guide="right"] { transform: rotate(0deg); }
.guide-track[data-guide="down"] { transform: rotate(90deg); }
.guide-track[data-guide="left"] { transform: rotate(180deg); }
.guide-track[data-guide="up"] { transform: rotate(270deg); }
@keyframes guide-finger {
  0% { transform: translateX(0) scale(1.15); opacity: 0; }
  12% { transform: translateX(0) scale(0.9); opacity: 1; }
  62% { transform: translateX(var(--len, 90px)) scale(0.9); opacity: 1; }
  80%, 100% { transform: translateX(var(--len, 90px)) scale(1.15); opacity: 0; }
}
@keyframes guide-trail {
  0%, 12% { transform: scaleX(0); opacity: 0.9; }
  62% { transform: scaleX(1); opacity: 0.9; }
  80%, 100% { transform: scaleX(1); opacity: 0; }
}
.guide-text { position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%); margin: 0; white-space: nowrap;
  padding: 6px 12px; border-radius: 16px; background: rgba(11, 20, 38, 0.88); border: 1px solid var(--warm);
  color: var(--warm); font-size: 14px; animation: guide-text 1.6s ease-in-out infinite alternate; }
@keyframes guide-text { from { opacity: 0.75; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .guide-finger { animation: none; transform: translateX(calc(var(--len, 90px) / 2)); }
  .guide-trail { animation: none; }
}
@media (max-height: 700px) { h1 { font-size: 18px; } }
