/* 游戏页面：暖纸色底；游戏 UI 极简（圆形按钮 + 引导层）；调试面板是深色半透明的开发工具（样式沿用 Shepherd） */
:root {
  --paper: #ece7de;
  --ink: #2a2140;
  --cream: #f6ecd8;
  --ui-font-size: 12px;
  --panel-width: 380px;
  --ui-bg: rgba(18, 18, 21, 0.9);
  --ui-bg-solid: #141417;
  --ui-field: #2a2a30;
  --ui-field-hover: #34343b;
  --ui-fg: #e6e6e6;
  --ui-muted: #8d8d96;
  --ui-line: #34343a;
  --ui-accent: #4fb6f0;
  --ui-mod: #f0c75a;
  --ui-danger: #ff6b5e;
  --ui-ok: #5fd08a;
  --font: ui-monospace, 'SF Mono', Menlo, 'PingFang SC', 'Microsoft YaHei', monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  /* 0.2.0-rc.3：和场景背景同色（加载时画布还没画出来，不闪一下米色） */
  background: linear-gradient(var(--bg1, #d8d8d5), var(--bg2, #cbcbc8)) fixed;
  color: var(--ui-fg);
  font: var(--ui-font-size) / 1.45 var(--font);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
input, textarea, [contenteditable] { -webkit-user-select: text; user-select: text; }
/* 0.2.0-rc.3：100% 而不是 100vw / 100vh——iOS Safari 的 100vh 比可见区域高，画面会被竖着拉长 */
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; cursor: grab; }
#view.grabbing { cursor: grabbing; }
#view.pick { cursor: pointer; }
[hidden] { display: none !important; }
button, select, input { font: inherit; color: inherit; border-radius: 0; }

/* ---------- 游戏 UI ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud .round {
  position: absolute;
  bottom: max(18px, env(safe-area-inset-bottom));
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 0;
  background: #fff;
  box-shadow: 0 2px 0 rgba(42, 33, 64, 0.16), 0 6px 18px rgba(42, 33, 64, 0.12);
  cursor: pointer;
  pointer-events: auto;
  display: grid;
  place-items: center;
  transition: transform 0.12s;
}
#hud .round:hover { transform: scale(1.06); }
#hud .round:active { transform: scale(0.94); }
/* rc.8：按下的反馈——一圈细环从按钮扩散出去（rc.10：背景调亮以后用提示颜色，不加描边） */
#hud .round::after { content: ''; position: absolute; inset: -2px; border-radius: 50%; border: 2px solid var(--hint, var(--ink)); opacity: 0; pointer-events: none; }
#hud .round.tap::after { animation: arm-tap 0.45s ease-out; }
@keyframes arm-tap { from { opacity: 0.6; transform: scale(1); } to { opacity: 0; transform: scale(1.7); } }
#hud .round svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
#btn-restart { left: 18px; }
#btn-debug { right: 18px; opacity: 0.55; }
#btn-debug:hover { opacity: 1; }
#hints, #force { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
#force .force path { fill: none; stroke: var(--force, var(--ink)); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.9)); }
#force .force circle { fill: #fff; stroke: var(--force, var(--ink)); stroke-width: 3; }
#view.grip { cursor: grab; }
#win {
  position: absolute; top: 28px; left: 50%; transform: translateX(-50%);
  background: #fff; color: var(--ink); border-radius: 999px; padding: 8px 22px;
  font: 700 26px 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif; font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 0 rgba(42, 33, 64, 0.16), 0 6px 18px rgba(42, 33, 64, 0.12);
  animation: win-in 0.5s cubic-bezier(0.2, 1.4, 0.4, 1);
}
#win .unit { font-size: 15px; margin-left: 4px; opacity: 0.6; }
@keyframes win-in { from { transform: translateX(-50%) scale(0.6); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }
/* rc.8 起手绘风的笔触（圈、箭头）；rc.10：不加投影、不加描边，字换成标准无衬线体；
   背景调亮以后白色没有投影就看不见了，颜色改用墨色（面板「提示颜色」可改，--hint 由 main.js 设） */
#hints .sk { fill: none; stroke: var(--hint, var(--ink)); stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; opacity: 0.88; }
#hints .sk.thin { stroke-width: 2.1; }
#hints .sk-dot { fill: var(--hint, var(--ink)); opacity: 0.88; }
#hints text { font: 600 16px -apple-system, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif; fill: var(--hint, var(--ink)); letter-spacing: 0.3px; }
/* 开局水平仪（3D，画在场景里）→ 选球页的换场遮罩：和场景同一个背景色的整屏层，淡入、换、淡出 */
#intro {
  position: fixed; inset: 0; z-index: 8; pointer-events: none;
  background: linear-gradient(var(--bg1, #d8d8d5), var(--bg2, #cbcbc8));
}
body.flow-boot #view { cursor: grab; }
body.flow-boot #view:active { cursor: grabbing; }
/* 加载 / 水平仪时不显示圆按钮（游戏还没起来）；流程没走到游戏时不显示「重来」 */
body.flow-boot #hud .round { display: none; }
body.flow-select #btn-restart, body.flow-enter #btn-restart { display: none; }
body.flow-select #view { cursor: pointer; }

/* rc.12：屏幕正下方的一行说明（死了、到达记录点）：墨色无衬线字 + 小图标，不加底、不加投影 */
#caption {
  position: absolute; left: 50%; bottom: 22px; transform: translate(-50%, 8px);
  display: flex; align-items: center; gap: 8px; white-space: nowrap; pointer-events: none;
  color: var(--hint, var(--ink)); font: 600 17px -apple-system, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif; letter-spacing: 0.4px;
  opacity: 0; transition: opacity 0.35s ease, transform 0.45s cubic-bezier(0.2, 1.2, 0.4, 1);
}
#caption.on { opacity: 0.9; transform: translate(-50%, 0); }
#caption svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }
#caption svg .fill { fill: var(--beacon, #3fd99a); }
#caption svg .dot { fill: currentColor; stroke: none; }
#caption svg .ok { stroke: var(--beacon, #3fd99a); stroke-width: 2.6; }
#caption.idle { animation: caption-breathe 2.4s ease-in-out infinite; }
@keyframes caption-breathe { 50% { opacity: 0.55; } }
#toasts { position: absolute; bottom: 80px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 4px; }
.toast { background: var(--ui-bg-solid); border-left: 3px solid var(--ui-muted); color: var(--ui-fg); padding: 5px 10px; transition: opacity 0.4s; }
.toast-ok { border-left-color: var(--ui-ok); }
.toast-error { border-left-color: var(--ui-danger); }
.toast.out { opacity: 0; }

body.ui-hidden #hud, body.ui-hidden .p-panel, body.ui-hidden .p-tip { display: none !important; }
body.panel-hidden .p-panel, body.panel-hidden .p-tip { display: none !important; }

#boot-error {
  position: fixed;
  inset: 30% 10% auto;
  background: var(--ui-bg-solid);
  border: 1px solid var(--ui-danger);
  color: var(--ui-fg);
  padding: 12px;
  white-space: pre-wrap;
  z-index: 40;
}

/* ---------- 调试 / 参数面板 ---------- */
.p-panel {
  position: fixed;
  top: 10px;
  right: 10px;
  width: var(--panel-width);
  max-height: calc(100vh - 20px);
  display: flex;
  flex-direction: column;
  background: var(--ui-bg);
  border: 1px solid #2c2c33;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
  z-index: 10;
  line-height: 1.5;
  color: var(--ui-fg);
}
.p-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: grab;
  border-bottom: 1px solid var(--ui-line);
  background: rgba(255, 255, 255, 0.04);
  touch-action: none;
}
.p-head:active { cursor: grabbing; }
.p-head b { font-size: 1.08em; }
.p-head-ver { color: var(--ui-muted); }
.p-fps { color: var(--ui-muted); font-variant-numeric: tabular-nums; }
.p-head-caret { margin-left: auto; width: 0; height: 0; border: 5px solid transparent; border-top-color: var(--ui-fg); transform: translateY(3px); }
.p-panel.collapsed .p-head-caret { transform: rotate(90deg) translateX(2px); }
.p-panel.collapsed .p-head { border-bottom: 0; }
.p-panel.collapsed .p-body { display: none; }
.p-body { display: flex; flex-direction: column; min-height: 0; }
.p-mode { font: inherit; font-weight: 700; color: inherit; opacity: 0.55; background: transparent; border: none; padding: 2px 8px; border-radius: 4px; cursor: pointer; }
.p-mode.active { opacity: 1; background: rgba(255, 255, 255, 0.14); }
.p-pane { display: flex; flex-direction: column; min-height: 0; }
.p-pane[hidden] { display: none; }

.p-panel button { border: 1px solid #44444d; background: #2e2e35; padding: 4px 10px; cursor: pointer; white-space: nowrap; }
.p-panel button:hover { background: #3a3a43; border-color: #5a5a66; }
.p-panel button.primary { background: var(--ui-accent); border-color: var(--ui-accent); color: #061620; font-weight: 600; }
.p-panel button:disabled { opacity: 0.5; }
.p-quick { padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; border-bottom: 1px solid var(--ui-line); }
.p-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.p-actions button { flex: 1 1 auto; }
.p-status { display: flex; align-items: center; gap: 8px; color: var(--ui-muted); }
.p-dirty.dirty { color: var(--ui-mod); }
.p-dirty.dirty::before { content: ''; display: inline-block; width: 7px; height: 7px; background: var(--ui-mod); margin-right: 6px; }
.p-search, .p-panel select, .p-panel input[type='number'], .p-panel input[type='text'] {
  background: #26262c; border: 1px solid #3c3c45; padding: 3px 6px; outline: none; min-width: 0; color: var(--ui-fg);
}
.p-search:focus, .p-panel input:focus, .p-panel select:focus { border-color: var(--ui-accent); }

.p-tabs { display: flex; border-bottom: 1px solid var(--ui-line); }
.p-panel .p-tabs button { flex: 1; border: 0; border-right: 1px solid var(--ui-line); background: transparent; padding: 6px 2px; color: var(--ui-muted); }
.p-panel .p-tabs button:last-child { border-right: 0; }
.p-panel .p-tabs button:hover { color: var(--ui-fg); background: rgba(255, 255, 255, 0.04); }
.p-panel .p-tabs button.active { color: var(--ui-fg); background: #2a2a31; box-shadow: inset 0 -2px 0 var(--ui-accent); font-weight: 600; }
.p-panel.searching .p-tabs { display: none; }
.p-content { overflow-y: auto; overscroll-behavior: contain; min-height: 0; }
.p-content::-webkit-scrollbar { width: 8px; }
.p-content::-webkit-scrollbar-thumb { background: #4a4a54; }
.p-tab-title { display: none; padding: 5px 10px; color: var(--ui-accent); border-bottom: 1px solid var(--ui-line); }
.p-panel.searching .p-tab-title { display: block; }

.p-sec { border-bottom: 1px solid var(--ui-line); }
.p-sec-head { display: flex; align-items: center; gap: 7px; padding: 6px 10px; cursor: pointer; font-weight: 600; color: #ececf0; }
.p-sec-head:hover { background: rgba(255, 255, 255, 0.05); }
.p-caret { width: 0; height: 0; border: 4px solid transparent; border-left-color: var(--ui-muted); margin-right: -2px; }
.p-sec.open .p-caret { transform: rotate(90deg) translateX(2px); }
.p-count { margin-left: auto; color: var(--ui-mod); font-weight: 400; }
.p-sec-body { display: none; padding: 0 0 6px; }
.p-sec.open .p-sec-body, .p-panel.searching .p-sec-body { display: block; }
.p-sec-body > .p-actions, .p-sec-body > .p-keys, .p-sec-body > .p-note { padding: 5px 10px 5px 16px; }
.p-note { color: var(--ui-muted); margin: 0; }
.p-keys div { display: flex; justify-content: space-between; padding: 2px 0; color: var(--ui-muted); }
.p-keys kbd { font: inherit; color: var(--ui-fg); }

.p-row { display: grid; grid-template-columns: 40% 1fr 18px; align-items: center; gap: 8px; padding: 2px 6px 2px 16px; min-height: 26px; border-left: 2px solid transparent; }
.p-row:hover { background: rgba(255, 255, 255, 0.06); }
.p-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #dcdce2; }
.p-row.is-mod { border-left-color: var(--ui-mod); background: rgba(240, 199, 90, 0.07); }
.p-row.is-mod .p-label { color: var(--ui-mod); }
.p-regen { font-style: normal; color: var(--ui-muted); margin-left: 3px; }
.p-ctl { display: flex; align-items: center; gap: 5px; min-width: 0; }
.p-ctl select { width: 100%; }
.p-panel .p-reset { visibility: hidden; padding: 0; border: 0; background: none; color: var(--ui-muted); width: 18px; }
.p-row.is-mod .p-reset { visibility: visible; }
.p-panel .p-reset:hover { color: var(--ui-fg); background: none; }
.p-panel input[type='range'] {
  -webkit-appearance: none; appearance: none; flex: 1; min-width: 0; height: 18px; margin: 0;
  background: linear-gradient(var(--ui-accent), var(--ui-accent)) 0 50% / var(--pct, 0%) 100% no-repeat, #2b2b32;
  border: 1px solid #3c3c45; cursor: ew-resize;
}
.p-row.is-mod input[type='range'] { background: linear-gradient(var(--ui-mod), var(--ui-mod)) 0 50% / var(--pct, 0%) 100% no-repeat, #2b2b32; }
.p-panel input[type='range']::-webkit-slider-thumb { -webkit-appearance: none; width: 3px; height: 18px; background: #fff; }
.p-panel input[type='range']:hover { filter: brightness(1.12); }
.p-num { width: 62px; text-align: right; -moz-appearance: textfield; }
.p-num::-webkit-inner-spin-button, .p-num::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.p-panel input[type='color'] { width: 30px; height: 20px; padding: 0; border: 1px solid #3c3c45; background: none; cursor: pointer; }
.p-panel input[type='color']::-webkit-color-swatch-wrapper { padding: 0; }
.p-panel input[type='color']::-webkit-color-swatch { border: 0; border-radius: 0; }
.p-hex { flex: 1; }
.p-check { display: inline-flex; cursor: pointer; }
.p-check input { display: none; }
.p-check span { width: 16px; height: 16px; background: #26262c; border: 1px solid #50505a; }
.p-check input:checked + span { background: var(--ui-accent); border-color: var(--ui-accent); box-shadow: inset 0 0 0 3px #26262c; }
.p-row.is-mod .p-check input:checked + span { background: var(--ui-mod); border-color: var(--ui-mod); }

.p-tip {
  position: fixed; z-index: 50; width: 260px; background: var(--ui-bg-solid); border: 1px solid var(--ui-line);
  border-left: 2px solid var(--ui-accent); padding: 7px 9px; pointer-events: none; display: flex; flex-direction: column; gap: 4px; line-height: 1.5; color: var(--ui-fg);
}
.p-tip b { color: var(--ui-fg); }
.p-tip-meta { color: var(--ui-muted); display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }

/* 调试页里的只读数据 */
.p-stats { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 5px 10px 5px 16px; color: var(--ui-muted); font-variant-numeric: tabular-nums; }
.p-stats b { color: var(--ui-fg); font-weight: 500; }
.p-falls { display: flex; flex-wrap: wrap; gap: 3px; padding: 4px 10px 4px 16px; }
.p-falls span { min-width: 26px; text-align: center; padding: 1px 3px; background: #26262c; border: 1px solid #3c3c45; color: var(--ui-muted); }
.p-falls span.cur { border-color: var(--ui-accent); color: var(--ui-fg); }
.p-falls span.hot { color: var(--ui-danger); }

@media (max-width: 720px) {
  .p-panel { width: calc(100vw - 16px); top: auto; bottom: 8px; max-height: 60vh; }
}
