* {
    margin: 0;
    padding: 0;
    touch-action: none;
}

body {
    background-color: rgb(102, 102, 102);
    overflow: hidden;
    font-family: "Arial", sans-serif;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.tooltip {
    position: relative;
    cursor: pointer;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    font-size: 12px;
    padding: 6px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 10;
    -webkit-transform: translateX(-50%);
    -moz-transform: translateX(-50%);
    -ms-transform: translateX(-50%);
    -o-transform: translateX(-50%);
}
.tooltip.messages::after{
    margin-left:-30px ;
}
.tooltip#info::after{
    margin-left:-25px ;
}
.hidehotspotText > svg {
    opacity: 0.3;
}
.tooltip:hover::after {
    opacity: 1 !important;
}

.hidden {
    display: none !important;
}

.input-selector {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background: white url("data:image/svg+xml;charset=UTF-8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path fill='black' d='M0 0l5 6 5-6z'/></svg>") no-repeat right 12px center;
  background-size: 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 8px 24px 8px 12px;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s ease;
}


#ui {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#ui * {
    pointer-events: auto;
}

/* #hotspotPanel{
    display:flex;
    justify-content:center;
    align-items:center
} */
#hotspotContent {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translate(-50%, 0);
    min-width: 300px;
    padding: 16px;
    border-radius: 10px;
    color: #111827;
    background-color: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}
.hotspotWrapper {
    position: relative;
    padding:8px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    -webkit-border-radius: 4px;
    -moz-border-radius: 4px;
    -ms-border-radius: 4px;
    -o-border-radius: 4px;
    border-radius: 4px;
    border: 1px solid white;
}
.hotspotWrapper .hotspotTitle{
    position: absolute;
    width: max-content;
    height: max-content;
    font-size: 15px;    
    padding: 0px 2px;
    top: -12px;
    left: 12px;
    background-color: #ccc;
    border: 1px solid #ccc;
    color: #f95f4d;
}

.hotspot {
    display: flex;
    justify-content: center;
    border-radius: 5px;
    align-items: center;
    position: absolute;
    padding: 8px;
    min-width: max-content;
    min-height: max-content;
    /* box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); */
    cursor: grab;
    pointer-events: auto;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    box-sizing: border-box;
}
.hotspot span{
    display: block;
    text-align: center;
    width: 100%
}
.hotspot-close {
    position: absolute;
    top: 2px;
    right: 4px;
    cursor: pointer;
    font-weight: bold;
    color: #888;
    padding: 0 4px;
    user-select: none;
}
#hotspotSave{
    width: 80px;
    height: 32px;
    padding: 0;
    margin: 0;
    color: #fff;
    background-color: #f95f4d;
    border: 1px solid #f95f4d;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    letter-spacing: -0.25px;
}
#hotspotSave:hover {
    background-color: rgb(255, 115, 99);
    border-color: rgb(255, 115, 99);
    color: white;
}

.hotspot-close:hover {
    color: #f00;
}

/* input itself */
.hotspotInput {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    outline: none;
    font-size: 14px;
    color: #111827;
    background: #fff;
    padding: 8px 10px;
    min-width: 180px;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}
#buttonTitle{
    min-width: 100px;
}
#edit {
    position: fixed;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 8px;
    top: 0;
    overflow: auto;
    left: 0;
    width: 100vw;
    height: max-content;
    background-color: #ccc;
    gap: 8px;
}
.text-editor-toolbar {
  display: flex;
  gap: 4px;
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s;
  color: #333;
}
.btn-icon.active{
    background: rgba(0,0,0,0.05);
}


.btn-icon svg {
  width: 20px;
  height: 20px;
}

.inputWrapper {
    display: flex;
    align-items: center;
    gap: 2px;
}
.inputWrapper span{
    font-size: 14px;
    min-width:max-content;
}
.input {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    outline: none;
    font-size: 14px;
    color: #111827;
    background: #fff;
    padding: 4px 8px;
    height: 24px;
    width: 52px;
    text-align: center;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

/* placeholder */
.hotspotInput::placeholder {
    color: #9ca3af;
    opacity: 1;
}

/* focus state */
.hotspotInput:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}
#addHotspotBtn {
    padding: 8px;
    cursor: pointer;
}
#infoPanel,
#hotspotPanel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
}

#infoPanel > #infoPanelContent {
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translate(-50%, 0);
    min-height: 180px;
    min-width: 300px;
    padding: 8px;
    border-radius: 24px;
    color: black;
    background-color: #eeed;
    display: flex;
    flex-direction: column;
}

#infoPanel > #infoPanelContent > #header {
    font-size: 24px;
    font-weight: bold;
    padding-bottom: 16px;
    color: #444;
    display: none;
}

#infoPanel > #infoPanelContent > #tabs {
    display: flex;
    gap: 16px;
    background-color: #666;
    padding: 8px;
    border-radius: 22px;
}

#infoPanel > #infoPanelContent > #tabs > .tab {
    padding: 8px;
    border-radius: 16px;
    cursor: pointer;
    flex-grow: 1;
    text-align: center;
    font-weight: bold;
    font-size: 14px;
    color: #222;
    transition: background-color 250ms ease;
}

#infoPanel > #infoPanelContent > #tabs > .tab:hover {
    background-color: #eee;
}

#infoPanel > #infoPanelContent > #tabs > .tab.active {
    background-color: #eee;
}

#infoPanel > #infoPanelContent > #infoPanels {
    padding: 16px;
}

#infoPanel > #infoPanelContent .control-item {
    display: flex;
    justify-content: space-between;
    gap: 32px;
    line-height: 1.5;
}

#infoPanel > #infoPanelContent > #infoPanels h1 {
    font-size: 14px;
    font-weight: bold;
    padding: 0 0 6px 0;
}

#infoPanel > #infoPanelContent .control-item > .control-action {
    text-align: left;
    color: #333;
}

#infoPanel > #infoPanelContent .control-item > .control-key {
    text-align: right;
    color: #666;
}

#infoPanel > #infoPanelContent .control-spacer {
    border-bottom: 1px dashed #666;
    margin: 10px 0;
}

/* loadingWrap - 增強版本 */

#loadingWrap {
    position: fixed;
    bottom: 120px;
    left: 50%;
    transform: translate(-50%, 0);
    width: 380px;

    display: flex;
    flex-direction: column;

    padding: 16px;
}

/* 新增的檔案大小顯示 */
#fileSizeInfo {
    font-size: 14px;
    color: #f95744;
    text-align: center;
    margin-bottom: 4px;
    text-shadow: 0 0 4px rgba(0, 0, 0, 0);
    font-weight: 500;
}

#loadingWrap > #loadingText {
    font-size: 18px;
    color: #f95744;
    text-align: center;
    text-shadow: 0 0 4px rgba(0, 0, 0, 0);
}

#loadingWrap > #loadingBar {
    width: 100%;
    height: 10px;
    margin-top: 8px;
    border-radius: 4px;
    overflow: hidden;
    background: #333;
    border: 1px solid #555;
}

/* controlsWrap */

#buttonWrapper {
    position: absolute;
    display: flex;
    gap: 8px;
    width: 100%;
    height: 100%;
    margin-bottom: 12px;
    align-items: end;
    justify-content: flex-end;
    pointer-events: none;
}
#hotspotBtnWrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-right: 12px;
}
#controlsWrap,
#hotspotBtnWrapper {
    margin-bottom: 12px;
}
#controlsWrap {
    pointer-events: auto;
    display: flex;
    gap: 4px;
    flex-direction: column;
}
.hotspotDot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    pointer-events: none;
    position: absolute;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
    /* animation: blink 1s infinite alternate; */
}

@keyframes blink {
    0% {
        opacity: 0.8;
    }
    50% {
        opacity: 0.6;
    }
    100% {
        opacity: 0.8;
    }
}

.hotspotBtn {
    position: relative;
    width: 100%;
    min-width: max-content;
    padding: 8px;
    font-size: 18px;
    border: none;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    -webkit-border-radius: 4px;
    -moz-border-radius: 4px;
    -ms-border-radius: 4px;
    -o-border-radius: 4px;
    border-radius: 4px;
}
.closeBtn {
    position: absolute;
    top: -8px;
    right: -8px;
    cursor: pointer;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hotspotBtn:hover {
    background-color: #f0f0f0;
    color: #333;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.hotspotBtn:active {
    transform: translateY(0px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    background-color: #e0e0e0;
    color: #333;
}

#controlsWrap.faded-in,
#hotspotBtnWrapper.faded-in {
    visibility: visible;
    opacity: 1;
    transition: opacity 0.5s ease-out;
}

#controlsWrap.faded-out,
#hotspotBtnWrapper.faded-out {
    visibility: hidden;
    opacity: 0;
    transition:
        visibility 0s 0.5s,
        opacity 0.5s ease-out;
}

#controlsWrap > #timelineContainer {
    height: 30px;
    cursor: pointer;
}

#controlsWrap > #timelineContainer > #line {
    width: 100%;
    height: 50%;
    border-bottom: 1px solid #8888;
}

#controlsWrap > #timelineContainer > #handle {
    position: absolute;
    top: 15.5px;
    width: 10px;
    height: 10px;
    transform: translate(-50%, -50%);
    border: 1px solid black;
    border-radius: 50%;
    background-color: #fff8;
}

#controlsWrap > #timelineContainer > #time {
    position: absolute;
    top: 0;
    padding: 2px 4px;
    transform: translate(-50%, -100%);
    font-size: 12px;
    color: white;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 4px;
}
#playContainer {
    justify-content: flex-end;
}

#controlsWrap > #buttonContainer,
#playContainer {
    display: flex;
    gap: 8px;
}

/* spacer */

.spacer {
    flex-grow: 1;
}

/* settingsPanel */

#settingsPanel {
    position: fixed;
    right: max(16px, env(safe-area-inset-right));
    bottom: calc(max(16px, env(safe-area-inset-bottom)) + 70px);
    padding: 10px;
    color: #eee;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 8px;

    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;

    font-size: 14px;
}

#settingsPanel > .settingsRow {
    display: flex;
    gap: 4px;
    width: 100%;
}

#settingsPanel > .settingsRow > .button {
    padding: 10px 0px;
    flex-grow: 1;
}

/* toggleWrap */

.toggleWrap {
    position: relative;
    background-color: #dddd;
    border: 1px solid #888;
    border-radius: 8px;
    height: 40px;
    width: 120px;
}

.toggleWrap > .toggleHighlight {
    position: absolute;
    left: 0;
    width: 50%;
    height: 100%;
    background-color: #eee;
    border-radius: 8px;
    transition: left 0.1s ease-out;
}

.toggleWrap > .toggleHighlight.right {
    left: 60px;
}

.toggleWrap > button {
    position: absolute;
    width: 60px;
    height: 100%;
    border: 0;
    border-radius: 8px;

    cursor: pointer;
    font-size: 14px;
    letter-spacing: -0.25px;

    color: #222;
    background-color: transparent;

    appearance: none;
}

.toggleWrap > button:hover {
    color: black;
}

.toggleWrap > button.left {
    left: 0;
}

.toggleWrap > button.right {
    right: 0;
}

/* button */
.button {
    width: 40px;
    height: 40px;
    padding: 0;
    margin: 0;
    color: #222;
    background-color: #dddd;
    border: 1px solid #888;
    border-radius: 8px;
    cursor: pointer;

    /* font-weight: bold; */
    font-size: 14px;
    letter-spacing: -0.25px;
}

.button:hover {
    background-color: #eee;
}


.button > svg {
    display: block;
    margin: auto;
}

#poster {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

button {
    color: #222;
}

button:active {
    outline: none;
}

#joystickBase {
    position: absolute;
    width: 96px;
    height: 96px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    touch-action: none;

    background: radial-gradient(circle at center, #0000 50%, #000f 100%);
    background-color: #0002;
}

#joystickBase > #joystick {
    position: absolute;
    width: 48px;
    height: 48px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    touch-action: none;

    background-color: #fff8;
}

/* 移動設備特定優化 */
@media (max-width: 768px) {
    #loadingWrap {
        width: 90%;
        max-width: 320px;
        bottom: 100px;
    }

    #fileSizeInfo {
        font-size: 12px;
    }

    #loadingText {
        font-size: 16px;
    }

    /* 在手機上隱藏部分較少使用的按鈕以節省空間 */
    #arMode,
    #vrMode {
        display: none !important;
    }

    .button {
        width: 36px;
        height: 36px;
    }

    /* 設定面板在手機上的優化 */
    #settingsPanel {
        right: max(12px, env(safe-area-inset-right));
        bottom: calc(max(12px, env(safe-area-inset-bottom)) + 60px);
        padding: 8px;
        font-size: 12px;
    }

    .toggleWrap {
        width: 100px;
        height: 36px;
    }

    .toggleWrap > button {
        width: 50px;
        font-size: 12px;
    }

    .toggleWrap > .toggleHighlight.right {
        left: 50px;
    }
}

/* 極小螢幕優化 */
@media (max-width: 480px) {
    #loadingWrap {
        width: 95%;
        padding: 12px;
        bottom: 80px;
    }

    #fileSizeInfo {
        font-size: 11px;
    }

    #loadingText {
        font-size: 14px;
    }

    #loadingBar {
        height: 8px;
    }
}
#toast {
      position: fixed;
      left: 50%;
      transform: translateX(-50%);
      top: 4vh;
      min-width: 40px;
      max-width: 90%;
      padding: 8px 14px;
      border-radius: 999px;
      background: rgba(0,0,0,0.85);
      color: white;
      font-size: 16px;
      text-align: center;
      box-shadow: 0 6px 18px rgba(0,0,0,0.35);
      opacity: 0;
      pointer-events: none;
      transition: opacity 220ms ease, transform 220ms ease;
      z-index: 9999;
      display: inline-block;
      line-height: 1;
    }

    #toast.char {
      width: 44px;
      height: 44px;
      padding: 0;
      font-size: 20px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 50%;
    }

    #toast.show {
      opacity: 1;
      pointer-events: auto;
      transform: translateX(-50%) translateY(0);
    }

    #toast.success {
      background: rgba(34, 150, 76, 0.95); 
    }