/* Shared player shell. Authoring UI is opt-in on local desktop only. */
/* Touch navigation is only available on phones. Task-specific styles must not
   resurrect the pad on desktop or buttons hidden by the current control mode. */
body[data-device="desktop"] #mobilePad,
#mobilePad [hidden] {
  display: none !important;
  pointer-events: none !important;
}

html:not([data-tc-tools="true"]) :is(
  #tacheng-collision-debug-toggle, #tacheng-collision-debug-panel,
  #sceneStartEditor, #stonePuzzleEntryEditor, #anjihaiRingEditor,
  #anjihaiTrackEditor, #anjihaiHotspotEditor, #xbySceneEditor,
  .bkr-toggle, .bkr-panel, .bkr-layer, .mhp-toggle, .mhp-panel, .mhp-picker,
  .hmq-toggle, .hmq-settings, .hmq-pick, .hmq-pick-hint, .hmq-pick-cancel,
  #honglouMuseumQuest [data-action="configure"],
  #baketuTasks [data-action="edit-animals"], #baketuTasks .bkt-editor,
  .spg-toggle, .spg-panel, .spg-picker, .spg-pickbar,
  #tcLocalTools, #tcLightingPanel, #exportPatrolPointsJson,
  #openAdmin, #adminPanel, #honglouTimelineTestEntry, .honglou-test-entry,
  .hotspot-actions, .hotspot-add, .hotspot-export, .hotspot-delete,
  .debug-grid, .debug-toggle, #tunePanel .tune-group:not(.tune-group-basic), .fps-overlay
) { display: none !important; pointer-events: none !important; }

html[data-tc-player-ui="true"] {
  --tc-player-ink: #14231eee;
  --tc-player-line: #d5b66a8c;
  --tc-player-text: #fff1d0;
}
html[data-tc-player-ui="true"] :is(button, summary, [role="button"]):focus-visible {
  outline: 2px solid #e8ca78 !important;
  outline-offset: 3px;
}
html[data-tc-player-ui="true"] :is(button, summary):focus:not(:focus-visible) { outline: none !important; }
/* The region dropdown is the player's scene picker. Hide the duplicate dataset
   address list even before the shell module has initialized. */
html :is(.scene-panel, .scene-list, #sceneList) {
  display: none !important; visibility: hidden !important; pointer-events: none !important;
}

/* Desktop uses the phone's three HUD zones without changing device/input
   classification or rendering quality. This leaves touch-only controls alone. */
html[data-tc-player-ui="true"] body[data-device="desktop"] {
  --tc-player-top: max(12px, env(safe-area-inset-top));
  --tc-player-left: max(12px, env(safe-area-inset-left));
  --tc-player-right: max(12px, env(safe-area-inset-right));
  --tc-player-height: 38px;
}
html[data-tc-player-ui="true"] body[data-device="desktop"] :is(.scene-quick-actions .ui-toggle, #resetView, .topbar .brand, .top-actions select, .bottombar, .woven-frame, .corner-mark) { display: none !important; }
html[data-tc-player-ui="true"] body[data-device="desktop"]:not(.tacheng-mini-game-mode):not(.tacheng-anjihai-rally):not(.baketu-task-exploring):not(.baketu-camel-flight) :is(.scene-quick-actions, .topbar, .scene-menu) { display: block !important; }
html[data-tc-player-ui="true"] body[data-device="desktop"]:not(.tacheng-mini-game-mode):not(.tacheng-anjihai-rally):not(.baketu-task-exploring):not(.baketu-camel-flight) .fps-actions { display: flex !important; }
html[data-tc-player-ui="true"] body[data-device="desktop"]:not(.tacheng-mini-game-mode):not(.tacheng-anjihai-rally):not(.baketu-task-exploring):not(.baketu-camel-flight) #tunePanel { display: grid !important; }
html[data-tc-player-ui="true"] body[data-device="desktop"] :is(.scene-menu-toggle, #controlbar [data-control-mode], .audio-toggle, .weather-toggle, .hotspot-item, .control-trade-entry) {
  box-sizing: border-box;
  height: var(--tc-player-height) !important; min-height: var(--tc-player-height) !important;
  border: 1px solid var(--tc-player-line) !important;
  border-radius: 20px !important;
  background: var(--tc-player-ink); color: var(--tc-player-text);
  font-size: 13px !important; line-height: 1.2 !important;
  box-shadow: 0 3px 12px #0003;
}
html[data-tc-player-ui="true"] body[data-device="desktop"] :is(button, summary):hover { border-color: #f3d98f !important; }
html[data-tc-player-ui="true"] body[data-device="desktop"] #controlbar [data-control-mode][data-active="true"] { background: #315849 !important; color: #ffe5a0 !important; }
html[data-tc-player-ui="true"] body[data-device="desktop"] .scene-quick-actions {
  top: var(--tc-player-top) !important; left: 0 !important; right: 0 !important;
  height: var(--tc-player-height); pointer-events: none;
}
html[data-tc-player-ui="true"] body[data-device="desktop"] .scene-quick-actions > * { pointer-events: auto; }
html[data-tc-player-ui="true"] body[data-device="desktop"] .scene-menu {
  position: absolute !important; top: 0 !important; left: var(--tc-player-left) !important; right: auto !important; width: 160px !important;
}
html[data-tc-player-ui="true"] body[data-device="desktop"] .scene-menu-toggle { width: 100%; padding: 0 28px 0 14px !important; overflow: hidden; text-overflow: ellipsis; }
html[data-tc-player-ui="true"] body[data-device="desktop"] .scene-menu-list { width: 186px !important; transform: none !important; z-index: 30 !important; background: #14231ef7; }
html[data-tc-player-ui="true"] body[data-device="desktop"] #controlbar.controlbar {
  position: absolute !important; top: var(--tc-player-top) !important;
  left: calc(var(--tc-player-left) + 172px) !important; right: auto !important;
  width: max-content !important; max-width: none !important; height: var(--tc-player-height);
  display: flex !important; gap: 6px !important; transform: none !important;
  padding: 0 !important; background: none; border: 0; animation: none;
  pointer-events: none;
}
html[data-tc-player-ui="true"] body[data-device="desktop"] #controlbar.controlbar > * { pointer-events: auto; }
html[data-tc-player-ui="true"] body[data-device="desktop"][data-ui-collapsed="true"] #controlbar [data-control-mode]:not([hidden]),
html[data-tc-player-ui="true"] body[data-device="desktop"] #controlbar [data-control-mode]:not([hidden]) {
  width: 40px !important; min-width: 40px !important; padding: 0 !important; display: grid !important; place-items: center;
}
html[data-tc-player-ui="true"] body[data-device="desktop"] #controlbar [data-control-mode][hidden] { display: none !important; }
html[data-tc-player-ui="true"] body[data-device="desktop"] #controlbar .move-speed-control {
  position: fixed !important; top: var(--tc-player-top) !important; right: var(--tc-player-right) !important;
  left: auto !important; display: flex !important; width: 92px !important; height: 38px !important;
  min-height: 38px !important; padding: 4px !important; border-radius: 20px !important;
  background: var(--tc-player-ink); border: 1px solid var(--tc-player-line);
}
html[data-tc-player-ui="true"] body[data-device="desktop"] #controlbar .move-speed-control[hidden] { display: none !important; }
html[data-tc-player-ui="true"] body[data-device="desktop"] #controlbar .move-speed-control > span { display: none; }
html[data-tc-player-ui="true"] body[data-device="desktop"] #controlbar .move-speed-options { display: flex; gap: 2px; }
html[data-tc-player-ui="true"] body[data-device="desktop"] #controlbar .move-speed-options button { width: 40px; min-width: 0; min-height: 28px !important; height: 28px !important; padding: 0 !important; border-radius: 16px; font-size: 12px; }
html[data-tc-player-ui="true"] body[data-device="desktop"] #controlbar .control-trade-entry { position: fixed; top: 58px; left: var(--tc-player-left); width: max-content; padding: 0 14px; }

html[data-tc-player-ui="true"] body[data-device="desktop"] #tunePanel.tune-panel {
  top: var(--tc-player-top) !important; right: calc(var(--tc-player-right) + 102px) !important;
  left: auto !important; bottom: auto !important; width: 72px !important; max-width: none !important;
  max-height: none !important; padding: 0 !important; background: none !important;
  border: 0 !important; box-shadow: none !important; backdrop-filter: none !important; overflow: visible !important;
  animation: none; z-index: 8 !important;
}
html[data-tc-player-ui="true"] body[data-device="desktop"] .tune-group-basic { position: relative; display: block; padding: 0 !important; border: 0 !important; background: none !important; }
html[data-tc-player-ui="true"] body[data-device="desktop"] .tune-group-basic > summary {
  display: flex !important; align-items: center; justify-content: center; gap: 8px;
  width: 72px !important; height: 38px !important; min-height: 38px !important;
  padding: 0 12px !important; margin: 0 !important; font-size: 0 !important; list-style: none;
  border: 1px solid var(--tc-player-line); border-radius: 20px; color: var(--tc-player-text); background: var(--tc-player-ink);
}
html[data-tc-player-ui="true"] body[data-device="desktop"] .tune-group-basic > summary::-webkit-details-marker { display: none; }
html[data-tc-player-ui="true"] body[data-device="desktop"] .tune-group-basic > summary::before { content: "画质"; flex: none; white-space: nowrap; font-size: 13px; line-height: 1; }
html[data-tc-player-ui="true"] body[data-device="desktop"] .tune-group-basic > summary::after { content: "" !important; position: static !important; flex: none; width: 5px !important; height: 5px !important; margin: -3px 0 0; border: solid currentColor; border-width: 0 1px 1px 0; border-radius: 0; transform: rotate(45deg); }
html[data-tc-player-ui="true"] body[data-device="desktop"] .tune-group-basic[open] > summary::after { transform: translateY(3px) rotate(225deg); }
html[data-tc-player-ui="true"] body[data-device="desktop"] .tune-group-basic > :not(summary) { display: none !important; }
html[data-tc-player-ui="true"] body[data-device="desktop"] .tune-group-basic[open] > .quality-control { display: block !important; }
html[data-tc-player-ui="true"] body[data-device="desktop"] .quality-control > span { display: none !important; }
html[data-tc-player-ui="true"] body[data-device="desktop"] #qualityOptions {
  position: absolute; top: 44px; left: 50%; transform: translateX(-50%);
  display: grid !important; grid-template-columns: repeat(3, 1fr); gap: 4px; width: 214px;
  padding: 6px; border: 1px solid var(--tc-player-line); border-radius: 16px; background: #14231ef7;
}
html[data-tc-player-ui="true"] body[data-device="desktop"] #qualityOptions button { min-height: 36px; border-radius: 12px; padding: 0 8px; }
html[data-tc-player-ui="true"] body[data-device="desktop"] .fps-actions {
  top: var(--tc-player-top) !important; right: calc(var(--tc-player-right) + 184px) !important;
  left: auto !important; transform: none !important; gap: 6px !important;
}
html[data-tc-player-ui="true"] body[data-device="desktop"]:has(.move-speed-control[hidden]) #tunePanel.tune-panel { right: var(--tc-player-right) !important; }
html[data-tc-player-ui="true"] body[data-device="desktop"]:has(.move-speed-control[hidden]) .fps-actions { right: calc(var(--tc-player-right) + 82px) !important; }
html[data-tc-player-ui="true"] body[data-device="desktop"] .audio-actions { display: flex !important; gap: 6px; }
html[data-tc-player-ui="true"] body[data-device="desktop"]:is(.tacheng-mini-game-mode,.tacheng-anjihai-rally) .audio-actions { display: none !important; }
html[data-tc-player-ui="true"] body[data-device="desktop"] .audio-toggle { width: auto !important; min-width: 38px; padding: 0 12px !important; }
html[data-tc-player-ui="true"] body[data-device="desktop"] .hotspot-panel {
  top: calc(var(--tc-player-top) + 96px) !important; left: var(--tc-player-left) !important; right: auto !important;
  width: 160px !important; max-height: calc(100% - 240px) !important; padding: 0 !important;
  background: none !important; border: 0 !important; box-shadow: none !important; backdrop-filter: none !important;
}
html[data-tc-player-ui="true"] body[data-device="desktop"] .hotspot-panel .hotspot-row { width: 100%; }
html[data-tc-player-ui="true"] body[data-device="desktop"] .hotspot-panel .hotspot-list { display: grid; gap: 6px; }
html[data-tc-player-ui="true"] body[data-device="desktop"] .hotspot-panel .hotspot-row { display: block; }
html[data-tc-player-ui="true"] body[data-device="desktop"] .hotspot-panel .hotspot-title { display: none; }
html[data-tc-player-ui="true"] body[data-device="desktop"] .hotspot-panel .hotspot-item { width: 100%; padding: 0 12px; display: flex; align-items: center; justify-content: center; }
html[data-tc-player-ui="true"] body[data-device="desktop"] .hotspot-panel .hotspot-item strong { display: block; font-size: 13px; line-height: 1.2; margin: 0; }
html[data-tc-player-ui="true"] body[data-device="desktop"] .scene-quick-actions .weather-toggle { position: absolute; top: 46px; right: var(--tc-player-right); }
html[data-tc-player-ui="true"] body[data-device="desktop"]:is(.tacheng-mini-game-mode,.tacheng-anjihai-rally) :is(#controlbar, #tunePanel, .fps-actions, .scene-quick-actions, .hotspot-panel) { display: none !important; }
html[data-tc-player-ui="true"] body[data-device="desktop"].baketu-task-height-lock #controlbar.controlbar > :not(.move-speed-control) { display: none !important; }

/* Task-page buttons use the same upper-left / upper-right lanes as phones. */
html[data-tc-player-ui="true"][data-tc-mobile="false"] .scene-game::before,
html[data-tc-player-ui="true"][data-tc-mobile="false"] .scene-game::after { display: none; }
html[data-tc-player-ui="true"][data-tc-mobile="false"] #travelStoryHud .travelStoryHudContent {
  top: max(58px, calc(env(safe-area-inset-top) + 46px)) !important;
  right: max(12px, env(safe-area-inset-right)) !important; left: auto !important; bottom: auto !important;
  width: 228px !important;
}
html[data-tc-player-ui="true"][data-tc-mobile="false"] #travelStoryHint { display: none !important; }
html[data-tc-player-ui="true"][data-tc-mobile="false"] #travelStoryOpen { min-height: 38px !important; border-radius: 20px !important; font-size: 13px; }
html[data-tc-player-ui="true"][data-tc-mobile="false"] #baketuTasks .bkt-entry:not([hidden]),
html[data-tc-player-ui="true"][data-tc-mobile="false"] #hudLayer[data-game-active="false"] .mini-game-button:not([hidden]) {
  position: absolute !important; top: max(58px, calc(env(safe-area-inset-top) + 46px)) !important;
  left: max(12px, env(safe-area-inset-left)) !important; right: auto !important; bottom: auto !important;
  display: flex !important; align-items: center; gap: 6px; transform: none !important;
  min-height: 38px !important; height: 38px !important; max-width: 220px; padding: 0 14px !important;
  border: 1px solid var(--tc-player-line); border-radius: 20px !important; background: var(--tc-player-ink); color: var(--tc-player-text);
}
html[data-tc-player-ui="true"][data-tc-mobile="false"] #baketuTasks .bkt-entry small { display: none; }
html[data-tc-player-ui="true"][data-tc-mobile="false"] :is(.mini-game-button strong,.bkt-entry strong) { font-size: 13px !important; line-height: 1.2 !important; }
html[data-tc-player-ui="true"][data-tc-mobile="false"] #honglouMuseumQuest .hmq-status { top: 58px !important; left: 12px !important; padding: 8px 12px !important; max-width: 320px; }
html[data-tc-player-ui="true"][data-tc-mobile="false"] #honglouMuseumQuest .hmq-status button { min-height: 36px; font-size: 13px; }
html[data-tc-player-ui="true"][data-tc-mobile="false"] :is(.bkt-hud,.xby-search-hud) { max-width: 280px; }

/* Completion wins over the mobile/desktop rules that force entry buttons to
   display. Apply this in both the task page and its embedded viewer. */
html[data-tc-scene-tasks-complete="true"] body :is(#hudLayer button#openMiniGame, #openAnjihaiFragment, #controlTradeEntry, .scene-game-entry-fallback) {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}
html[data-tc-scene-tasks-complete="true"] body[data-device="mobile"] .hotspot-panel {
  top: calc(var(--tc-top) + var(--tc-h) + var(--tc-gap)) !important;
}
html[data-tc-player-ui="true"][data-tc-scene-tasks-complete="true"] body[data-device="desktop"] .hotspot-panel {
  top: calc(var(--tc-player-top) + 46px) !important;
}
