/* 共用样式。#world 内全部使用 720×1280 世界坐标像素，整个层由 JS 等比缩放。 */
:root {
  --gold-1: #fff3b0;
  --gold-2: #ffc83a;
  --gold-3: #e08a00;
  --ink: #17372d;
  --teal: #5fe9cf;
  --shade: rgba(8, 14, 10, 0.72);
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #1b1f1a;
  font-family: "Avenir Next", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}
#safe-probe {
  position: fixed; inset: 0; visibility: hidden; pointer-events: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
#decor {
  position: fixed; inset: -60px; background: #1b1f1a center / cover no-repeat;
  filter: blur(22px) brightness(0.55) saturate(1.1); pointer-events: none;
}
#screen { position: fixed; left: 0; top: 0; touch-action: none; display: block; }
#world {
  position: fixed; left: 0; top: 0; width: 720px; height: 1280px;
  transform-origin: 0 0; pointer-events: none; overflow: hidden;
}
#world button { pointer-events: auto; }
#game-ui, #overlay { position: absolute; inset: 0; }
[hidden] { display: none !important; }

/* ---------- 按钮：shared.ui.primary 底图 + 程序文字 ---------- */
.btn {
  position: absolute; border: 0; padding: 0 9%; margin: 0;
  background: url(../../assets/shared/shared.ui.primary.webp) center / 100% 100% no-repeat;
  color: var(--ink); font: inherit; font-weight: 900; font-size: 40px; letter-spacing: 0.5px;
  display: flex; align-items: center; justify-content: center; text-align: center;
  cursor: pointer; touch-action: manipulation;
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.35));
  transition: transform 0.08s ease, filter 0.08s ease;
}
.btn .btn-label { line-height: 1.05; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45); }
.btn:active:not(:disabled) { transform: translateY(4px) scale(0.97); filter: brightness(0.93) drop-shadow(0 3px 4px rgba(0, 0, 0, 0.35)); }
.btn:disabled { filter: grayscale(0.85) brightness(0.8) drop-shadow(0 6px 8px rgba(0, 0, 0, 0.3)); cursor: default; opacity: 0.85; }
.btn.small { font-size: 30px; background: rgba(10, 30, 25, 0.62); color: #eafff9; border: 3px solid rgba(95, 233, 207, 0.8); border-radius: 60px; padding: 0 20px; }

/* ---------- 浮层 ---------- */
.ov { position: absolute; inset: 0; }
.ov-loading, .ov-error { background: radial-gradient(ellipse at 50% 40%, #2b3a30 0%, #121813 75%); pointer-events: auto; }
.loading-spinner {
  position: absolute; left: 310px; top: 560px; width: 100px; height: 100px; border-radius: 50%;
  border: 10px solid rgba(255, 255, 255, 0.15); border-top-color: var(--gold-2);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text, .err-text, .err-detail, .pause-title {
  position: absolute; left: 40px; right: 40px; text-align: center; color: #f3f6ef; white-space: pre-line;
}
.loading-text { top: 700px; font-size: 34px; font-weight: 800; letter-spacing: 2px; opacity: 0.9; }
.loading-count { position: absolute; left: 0; right: 0; top: 752px; text-align: center; color: rgba(243, 246, 239, 0.6); font-size: 24px; }
.err-text { top: 520px; font-size: 38px; font-weight: 800; }
.err-detail { top: 640px; font-size: 22px; opacity: 0.6; font-family: ui-monospace, Menlo, monospace; }

.game-title, .result-title {
  position: absolute; left: 30px; right: 30px; text-align: center; font-weight: 900;
  background: linear-gradient(180deg, var(--gold-1) 0%, var(--gold-2) 55%, var(--gold-3) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: 3px #5a2c00;
  filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.55));
}
.ov-ready::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 330px;
  background: linear-gradient(180deg, rgba(10, 18, 10, 0.55), rgba(10, 18, 10, 0));
}
.game-title { top: 70px; font-size: 76px; line-height: 1.02; }
.game-subtitle {
  position: absolute; left: 30px; right: 30px; top: 240px; text-align: center;
  color: #fffbe8; font-size: 36px; font-weight: 800; text-shadow: 0 3px 8px rgba(0, 0, 0, 0.8);
}
.ov-pause { background: var(--shade); pointer-events: auto; }
.pause-title { top: 540px; font-size: 64px; font-weight: 900; }

.result-shade {
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(8, 14, 10, 0.7) 0%, rgba(8, 14, 10, 0) 25%),
    linear-gradient(0deg, rgba(8, 14, 10, 0.88) 0%, rgba(8, 14, 10, 0.6) 22%, rgba(8, 14, 10, 0) 36%);
}
.result-head { position: absolute; left: 24px; right: 24px; top: 64px; text-align: center; }
.result-head .result-title { position: static; font-size: 68px; line-height: 1.1; white-space: nowrap; }
body[data-state="result"] #game-ui { display: none; }
.is-fail .result-title { background: linear-gradient(180deg, #ffffff 0%, #ffd2c2 60%, #ff8e6e 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-stroke: 3px #5a1a00; }
.result-stat { margin-top: 10px; text-align: center; white-space: pre-line; line-height: 1.25; color: #f6f1de; font-size: 32px; font-weight: 700; text-shadow: 0 2px 6px #000; }
/* ---------- 页面级 UI（视口坐标，靠安全区） ---------- */
#page-ui { position: fixed; inset: 0; pointer-events: none; }
/* 结果页下载区的容器：由 sharedResultFooter 对齐到可见舞台；组件只让下载和 REPLAY 接收点击 */
.result-footer-host { position: absolute; pointer-events: none; }
/* 小手往右下挪：指尖只碰按键右下边缘，不贴 DOWNLOAD NOW 的字（组件原件不改，统一在这里覆盖） */
.result-footer-host .cdz-root { --cdz-hand-right: 0.5%; --cdz-hand-bottom: -17%; }
.pause-btn {
  position: absolute; pointer-events: auto; cursor: pointer;
  top: calc(env(safe-area-inset-top) + 10px); right: calc(env(safe-area-inset-right) + 10px);
  width: 44px; height: 44px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.7);
  background: rgba(10, 20, 15, 0.55); display: flex; gap: 6px; align-items: center; justify-content: center;
}
.pause-btn i { display: block; width: 5px; height: 16px; background: #fff; border-radius: 2px; }
.internal-badge {
  position: absolute; left: calc(env(safe-area-inset-left) + 2px); top: calc(env(safe-area-inset-top) + 2px);
  font: 700 8px/1.2 ui-monospace, Menlo, monospace; letter-spacing: 0.3px; color: #fff; white-space: nowrap;
  background: rgba(200, 30, 60, 0.75); padding: 2px 5px; border-radius: 3px;
}
.portrait-hint {
  position: absolute; top: 50%; transform: translateY(-50%); text-align: center;
  font-size: 14px; font-weight: 700; color: #fff; background: rgba(0, 0, 0, 0.6); padding: 8px 10px; border-radius: 12px;
  opacity: 0; visibility: hidden; transition: opacity 0.4s, visibility 0.4s;
}
.portrait-hint.show { opacity: 1; visibility: visible; }
.debug-panel {
  position: absolute; left: 4px; top: 4px; margin: 0; padding: 4px 6px; max-width: 70vw;
  font: 10px/1.35 ui-monospace, Menlo, monospace; color: #0f0; background: rgba(0, 0, 0, 0.6);
}

/* ---------- G04 HUD ---------- */
.g04-top { position: absolute; left: 30px; right: 30px; top: 18px; text-align: center; }
.g04-title {
  font-size: 58px; font-weight: 900; line-height: 1.05;
  background: linear-gradient(180deg, var(--gold-1) 0%, var(--gold-2) 55%, var(--gold-3) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: 2.5px #5a2c00; filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.6));
}
.g04-top-text { margin-top: 4px; color: #fffbe8; font-size: 30px; font-weight: 800; text-shadow: 0 3px 8px rgba(0, 0, 0, 0.9); }
.g04-goal { color: #ffe9a8; font-size: 24px; font-weight: 700; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9); }
.g04-meter {
  position: relative; margin: 8px auto 0; width: 420px; height: 32px; border-radius: 20px;
  background: rgba(8, 20, 16, 0.6); border: 3px solid rgba(255, 255, 255, 0.75); overflow: hidden;
}
.g04-meter-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; background: linear-gradient(90deg, #2fc7a8, var(--teal)); transition: width 0.06s linear; }
.g04-meter.is-low .g04-meter-fill { background: linear-gradient(90deg, #e0582f, #ffb04a); }
.g04-meter.is-timer .g04-meter-fill { background: linear-gradient(90deg, var(--gold-3), var(--gold-2)); transition: none; }
.g04-meter-label { position: absolute; inset: 0; color: #fff; font-size: 20px; font-weight: 800; line-height: 28px; text-shadow: 0 1px 3px #000; }
.g04-toast {
  position: absolute; left: 80px; right: 80px; top: 960px; text-align: center; padding: 16px 20px; border-radius: 40px;
  background: rgba(8, 18, 14, 0.8); color: #fff; font-size: 30px; font-weight: 800;
}
.g04-toast.show { animation: pop 0.25s ease-out; }
@keyframes pop { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- 其余九款共用 HUD（与 G04 同一视觉） ---------- */
.hud-top { position: absolute; left: 24px; right: 24px; top: 18px; text-align: center; pointer-events: none; }
.hud-title {
  font-size: 54px; font-weight: 900; line-height: 1.05; white-space: nowrap;
  background: linear-gradient(180deg, var(--gold-1) 0%, var(--gold-2) 55%, var(--gold-3) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: 2.5px #5a2c00; filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.6));
}
.hud-line { margin-top: 4px; color: #fffbe8; font-size: 30px; font-weight: 800; text-shadow: 0 3px 8px rgba(0, 0, 0, 0.95), 0 0 3px #000; }
.hud-goal { color: #ffe9a8; font-size: 24px; font-weight: 700; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.95), 0 0 3px #000; }
.hud-chips { margin-top: 8px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.hud-chip {
  display: inline-block; padding: 4px 16px; border-radius: 20px; font-size: 22px; font-weight: 800; color: #fff;
  background: rgba(8, 20, 16, 0.66); border: 2px solid rgba(255, 255, 255, 0.6);
}
.hud-chip.warn { border-color: #ff9c7a; color: #ffd9cc; }
.hud-chip.good { border-color: var(--teal); color: #d6fff6; }
.hud-toast {
  position: absolute; left: 60px; right: 60px; text-align: center; padding: 14px 20px; border-radius: 40px;
  background: rgba(8, 18, 14, 0.85); color: #fff; font-size: 30px; font-weight: 800; pointer-events: none;
  border: 3px solid rgba(255, 255, 255, 0.35);
}
.hud-toast.good { border-color: var(--teal); }
.hud-toast.bad { border-color: #ff8a6a; }
.hud-toast.show { animation: pop 0.25s ease-out; }
/* 可选工具托盘（G01 / G07）：按钮里放道具精灵，文字只用英文提示 */
.tray-slot {
  position: absolute; border-radius: 26px; border: 3px solid rgba(255, 233, 168, 0.85); padding: 0;
  background: radial-gradient(ellipse at 50% 40%, rgba(40, 60, 50, 0.72), rgba(8, 18, 14, 0.82));
  pointer-events: auto; cursor: pointer; touch-action: manipulation; box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}
.tray-slot canvas { width: 100%; height: 100%; display: block; pointer-events: none; }
.tray-slot:active { transform: scale(0.96); }
.tray-slot.is-wrong { border-color: #ff8a6a; opacity: 0.55; }
.tray-slot:disabled { cursor: default; }
/* G04：线还不够长时 TEST 按钮略暗，但仍可点（点了给英文提示） */
.btn.is-soft { filter: saturate(0.55) brightness(0.88) drop-shadow(0 6px 8px rgba(0, 0, 0, 0.3)); }

/* ---------- 操作提示（Coach）：手、接触圈、操作短句。全部不接收点击 ---------- */
.coach, .coach * { pointer-events: none; }
.coach { position: absolute; inset: 0; z-index: 4; }
.coach-hand { position: absolute; left: 0; top: 0; width: 150px; height: 137px; transform-origin: 24px 31px; opacity: 0; will-change: transform; }
.coach-hand img { width: 150px; height: 137px; display: block; filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.45)); }
.coach-ring {
  position: absolute; left: 0; top: 0; width: 120px; height: 120px; border-radius: 50%; opacity: 0; transform-origin: 60px 60px;
  border: 6px solid rgba(255, 255, 255, 0.95); box-shadow: 0 0 18px rgba(255, 236, 170, 0.8), inset 0 0 12px rgba(255, 236, 170, 0.6);
}
.coach-ring.g-hold { border-color: rgba(255, 255, 255, 0.55); background: conic-gradient(rgba(255, 214, 102, 0.85) var(--fill, 0deg), rgba(255, 255, 255, 0.12) 0);
  -webkit-mask: radial-gradient(circle, transparent 46%, #000 48%); mask: radial-gradient(circle, transparent 46%, #000 48%); }
.coach-label {
  position: absolute; transform: translate(-50%, -50%); white-space: nowrap;
  padding: 14px 34px; border-radius: 48px; background: rgba(10, 30, 25, 0.82); border: 4px solid rgba(255, 233, 168, 0.95);
  color: #fff; font-size: 34px; font-weight: 900; letter-spacing: 1.5px; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
  box-shadow: 0 8px 14px rgba(0, 0, 0, 0.35); transition: transform 0.08s ease-out, background 0.12s;
}
/* 长按区：更大的按压面，按下时下沉变亮 */
.coach-label.is-hold { padding: 22px 54px; font-size: 38px; border-width: 5px; }
.coach-label.is-hold::before { content: ""; display: inline-block; width: 22px; height: 22px; margin-right: 14px; border-radius: 50%;
  border: 4px solid rgba(255, 233, 168, 0.95); vertical-align: 1px; }
.coach-label.is-pressed { transform: translate(-50%, -50%) translateY(5px) scale(0.96); background: rgba(224, 138, 0, 0.95); box-shadow: 0 3px 6px rgba(0, 0, 0, 0.35); }
.coach-label.is-pressed::before { background: rgba(255, 233, 168, 0.95); }
.coach-label.is-warn { background: rgba(200, 40, 40, 0.95); border-color: #fff; }
.coach-label.is-strong { background: linear-gradient(180deg, #ffe08a, #f2b632); color: #3a2400; text-shadow: none; animation: coachPulse 0.9s ease-in-out infinite; }
.coach-label.is-small { font-size: 28px; padding: 10px 26px; }
@keyframes coachPulse { 50% { transform: translate(-50%, -50%) scale(1.06); } }
@media (prefers-reduced-motion: reduce) { .coach-label.is-strong { animation: none; } }
/* G10 当前动作按钮（FLIP / STOP / CATCH）：金色主按压面 */
.coach-label.is-action { padding: 12px 84px; font-size: 42px; letter-spacing: 3px; color: #3a2400; text-shadow: none;
  background: linear-gradient(180deg, #ffe08a, #f2b632); border-color: #fff6d8; }
.coach-label.is-action.is-pressed { background: linear-gradient(180deg, #f2b632, #d39316); }
/* V3：可以松手了（G03 RELEASE NOW!） */
.coach-label.is-go { background: linear-gradient(180deg, #ffe08a, #f2b632); color: #3a2400; text-shadow: none; border-color: #fff6d8; }
.coach-label.is-go::before { background: #3a2400; border-color: #3a2400; }

/* 优化策划 V1：挑战标题切换时轻微弹一下 */
.hud-title.hud-swap { animation: pop 0.3s ease-out; }
/* 操作区第二行小字（同时教“按住做什么 / 松手做什么”） */
.coach-label[data-sub]::after { content: attr(data-sub); display: block; font-size: 24px; font-weight: 800; letter-spacing: 1px; opacity: 0.85; margin-top: 2px; text-align: center; }
