.mobile-shot canvas, .mobile-shot #cueballPanel { touch-action: none; }
#mobileGuide, #mobileCamera { display: none; }
.mobile-shot #mobileGuide:not([hidden]) { display: block; position: absolute; inset: 0; pointer-events: none; }
#mobileGuide .guide-left, #mobileGuide .guide-right {
  position: absolute; top: 54%; width: clamp(166px, 22%, 280px);
}
#mobileGuide .guide-left { left: 4%; }
#mobileGuide .guide-right { right: 4%; }
#mobileGuide svg { display: block; overflow: visible; }
#mobileGuide text { fill: #fcf5dc; font-family: system-ui, sans-serif; }
#mobileGuide .head { font-size: 30px; font-weight: 600; }
#mobileGuide .sub { font-size: 21px; fill: #e0ddc5; }
#mobileGuideClose { position: absolute; right: -3px; top: -5px; background: transparent;
  border: 0; color: #f2e4c3; width: 44px; height: 44px; font-size: 21px; pointer-events: auto; }
#mobileGuide.swapped .guide-left { left: auto; right: 4%; }
#mobileGuide.swapped .guide-right { right: auto; left: 4%; }
.mobileTurnFx, #mobileSettings, #mobileSettingsShade { display: none; }
.mobile-shot #ui {
  --hud-edge: 8px;
  --player-height: 36px;
  --player-top: 4px;
  --player-width: clamp(136px, 17cqw, 150px);
  --spin-size: clamp(54px, 16cqh, 68px);
  --cream: #f0e2c9;
  --panel: linear-gradient(130deg, #36352ffc, #1b1d1afc 80%);
  font-family: system-ui, sans-serif;
}
.mobile-shot #ui .gamebar {
  box-sizing: border-box; width: var(--player-width); height: var(--player-height);
  left: var(--hud-edge) !important; top: var(--player-top) !important;
  border-radius: 7px; border: 1px solid #a59478;
  background: linear-gradient(112deg,#433b2d,#242622 46%,#181c19);
  box-shadow: inset 0 1px #f4d4a025, 0 2px 7px #0008;
}
.mobile-shot #ui:not(.local-seat-one) #gamebar1,
.mobile-shot #ui.local-seat-one #gamebar0 {
  top: calc(var(--player-top) + var(--player-height) + 4px) !important;
}
.mobile-shot body.practice #gameHudActions {
  top: calc(var(--player-top) + var(--player-height) + 4px);
}
.mobile-shot #turnBorder { width: 100%; height: 100%; overflow: visible; }
.mobile-shot #turnBorder > g:not(.mobileTurnFx) { display: none; }
.mobile-shot #turnBorder .mobileTurnFx { display: inline; }
.mobile-shot #turnBorder .mobileTurnArc {
  fill: none; stroke: url(#turnSpectrum); stroke-width: 2.3;
  stroke-dasharray: var(--turn-remaining, 0) 100;
}
.mobile-shot #turnBorder .halo { stroke-width: 5; opacity: .42; filter: blur(1.5px); }
#turnEmber {
  offset-path: url(#mobileTurnTrack);
  offset-distance: calc(var(--turn-remaining, 0) * 1%);
  offset-anchor: 0 0;
}
.mobile-shot #turnBorder:not(.counting) #turnEmber { display: none; }
.mobile-shot #turnBorder .spark {
  fill: #a4ffe0; animation: turnSpark .84s ease-out infinite; animation-delay: var(--delay);
}
.mobile-shot #turnBorder .spark:nth-of-type(3n) { fill: #ffe19e; }
.mobile-shot #turnBorder .spark:nth-of-type(3n + 1) { fill: #b9adff; }
@keyframes turnSpark {
  from { transform: translate(0,0) scale(1); opacity: 1; }
  to { transform: translate(var(--x),var(--y)) scale(.35); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .mobile-shot #turnBorder .spark { display: none; animation: none; }
}
.mobile-shot .gamebar .avatar {
  box-sizing: border-box; left: 3px; top: 2px; width: 30px; height: 30px;
  border: 1px solid #a8936c; border-radius: 5px;
}
.mobile-shot .gamebar .nickname {
  left: 37px; top: 2px; width: calc(100% - 41px); font-size: 12px; color: var(--cream);
}
.mobile-shot .gamebar .custom {
  left: 37px; top: 16px; height: 15px; width: calc(100% - 41px); display: flex; align-items: flex-start;
  gap: 1px; border-top: 1px solid #d6bd8f29; padding-top: 1px;
}
.mobile-shot .gamebar.has-open-pockets { overflow: visible; width: max-content; max-width: calc(100% - 16px); }
.mobile-shot .gamebar.has-open-pockets .custom {
  width: max-content; max-width: 70vw; border-top: 0; padding-top: 0;
}
.mobile-shot .gamebar.has-open-pockets .custom img { width: 14px; height: 14px; }
.mobile-shot .gamebar .custom img { width: min(calc((100% - 6px)/7), 14px); height: auto; }
.mobile-shot .gamebar .scoretext, .mobile-shot .gamebar .score { top: 18px; font-size: 12px; }
.mobile-shot .gamebar .scoretext { left: 37px; }
.mobile-shot .gamebar .score { left: 77px; }
.mobile-shot #matchExitDuringChoice, .mobile-shot #controlsGuideBtn, .mobile-shot #ui #timebar, .mobile-shot #groupball { display: none; }
.mobile-shot #mobileCamera:not([hidden]) {
  --camera-button-width: 36px;
  position: absolute; top: 6px; right: var(--hud-edge); z-index: 12; display: flex; gap: 4px;
}
.mobile-shot #mobileCamera button:not([hidden]) {
  position: relative; isolation: isolate; width: var(--camera-button-width); height: 44px;
  pointer-events: auto; color: var(--cream); border: 0; background: transparent; padding: 0;
  display: grid; place-items: center; font: 21px/1 system-ui;
}
.mobile-shot #mobileCamera button::before {
  content: ""; position: absolute; inset: 5px 0; z-index: -1;
  border: 1px solid #aa997b; border-radius: 7px; background: var(--panel);
}
#mobileCamera svg { width: 23px; height: 23px; }
#mobileCamera .glyph { display: none; }
#mobileCamera [data-mode=default] .default, #mobileCamera [data-mode=table] .table,
#mobileCamera [data-mode=end] .end, #mobileCamera [data-mode=cue] .cue { display: inline; }
.mobile-shot #mobileSettingsShade:not([hidden]) { display: block; position: absolute; inset: 0; z-index: 11; pointer-events: auto; }
.mobile-shot #mobileSettings:not([hidden]) {
  display: block; position: absolute; z-index: 13; right: var(--hud-edge); top: 59px;
  box-sizing: border-box; width: min(266px, 80%); max-height: calc(100% - 65px); overflow: auto;
  padding: 6px 16px; pointer-events: auto; color: var(--cream); background: var(--panel);
  border: 1px solid #b5a68b; border-radius: 10px; box-shadow: 0 4px 14px #0008;
  font: 600 15px/1.4 system-ui;
}
#mobileSettings header, #mobileSettings label {
  min-height: 42px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid #514e47;
}
#mobileSettings header { font-size: 19px; }
#mobileSettingsClose { border: 0; color: inherit; background: transparent; font: 24px system-ui; width: 40px; height: 42px; }
#mobileSettings .sensitivity { flex-wrap: wrap; padding: 8px 0; }
#mobileSettings input { accent-color: #82eac6; }
#mobileSettings input[type=range] { width: 100%; margin: 4px 0 0; }
#mobileSettings input[type=checkbox] { width: 19px; height: 19px; }
#mobileSettings #matchExitBtn { width: 100%; background: transparent; border: 0; color: #ef9890; }
#mobileCamera:has(#mobileSettingsBtn[aria-expanded=true])::after {
  content: ""; position: absolute; right: calc((var(--camera-button-width) - 8px) / 2);
  bottom: -14px; width: 8px; height: 8px;
  transform: rotate(45deg); background: #36352f; border: solid #b5a68b; border-width: 1px 0 0 1px;
}
#mobileSettings kbd { display: none; }
@container (max-width: 720px) {
  .mobile-shot #mobileCamera:not([hidden]) { --camera-button-width: 32px; right: 2px; gap: 2px; }
}
@container (max-width: 615px) {
  .mobile-shot #mobileCamera:not([hidden]) { top: 60px; }
  .mobile-shot #mobileSettings:not([hidden]) { top: 107px; max-height: calc(100% - 111px); }
}
.mobile-shot #mobilePlaceConfirm:not([hidden]) {
  position: absolute; right: var(--hud-edge); bottom: var(--hud-edge); left: auto; transform: none;
  z-index: 6; box-sizing: border-box; height: 40px; min-width: 120px; padding: 0 18px;
  border: 1px solid #e2c78a; border-radius: 8px; background: #d7b25ef0; color: #21180c;
  font: 600 15px/1 system-ui, sans-serif; pointer-events: auto;
}
.mobile-shot #mobilePlaceConfirm:disabled { opacity: .45; }
.mobile-shot #cueballPanel { width: var(--spin-size); height: var(--spin-size); left: var(--hud-edge) !important;
  top: auto !important; bottom: 22px; }
.mobile-shot #cueballPanel::after { content: "加塞"; position: absolute; top: 100%; left: 0; right: 0;
  text-align: center; color: #fbefd3; font: 500 12px/16px system-ui, sans-serif; text-shadow: 0 1px 3px #000; }
.mobile-shot #cueballPanel[inert] { pointer-events: none; opacity: .5; }
.mobile-shot #undoBtn { left: calc(var(--spin-size) + 16px); bottom: var(--hud-edge); }
@container (max-width: 580px) {
  .mobile-shot #undoBtn { bottom: 60px; }
}

/* Offset preview keeps the chosen contact visible above the player's thumb. */
.mobile-shot #cueballPanel.spin-drag::before {
  content: ""; position: absolute; left: 100%; bottom: 60%; width: 76px; height: 76px;
  border-radius: 50%; pointer-events: none; box-shadow: 0 2px 8px #0008;
  background: radial-gradient(circle at var(--spin-x) var(--spin-y), #e43c28 0 3px, transparent 4px),
    url("./common/cueball.png") center / cover;
}
.mobile-shot #cueballAim { border-radius: 50%; box-shadow: 0 0 0 1px #872512; }

/* 联机语音：手机上按钮放右下，说话声波放在玩家块右侧（块内放不下昵称和声波）。 */
.mobile-shot #voiceBtn { right: var(--hud-edge); bottom: 56px; width: 48px; height: 48px; gap: 2px; font-size: 9px; }
.mobile-shot #voiceBtn svg { width: 20px; height: 20px; }
.mobile-shot .gamebar .voice-wave { left: calc(100% + 4px); right: auto; top: 50%; margin-top: -9px;
  box-sizing: content-box; padding: 0 6px; width: 20px; height: 18px; border-radius: 9px;
  background: #181c19ee; border: 1px solid #a59478; }
