@import url("https://fonts.googleapis.com/css2?family=Bungee&family=Chiron+GoRound+TC:wght@200..900&display=swap");

* {
  box-sizing: border-box;
  font-family: "Chiron GoRound TC", sans-serif;
  font-weight: 900;
  touch-action: manipulation;
}

body {
  margin: 0;
  overflow: hidden;
  background-color: #f6f3eb;
  user-select: none;
  -webkit-user-select: none;
}

/* 提示文字 */
.hint {
  position: fixed;
  top: 30px;
  width: 100%;
  text-align: center;
  color: #725349;
  opacity: 0.5;
  font-size: 16px;
  letter-spacing: 1px;
  pointer-events: none;
  text-transform: uppercase;
  @media (max-width: 600px) {
    top: auto;
    bottom: 110px;
  }
}

/* 空狀態提示 */
#empty-message {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: #725349;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 0;
}
#empty-message.show {
  opacity: 0.4;
  visibility: visible;
}
#empty-message h2 {
  font-size: 40px;
  margin: 0;
}
#empty-message p {
  font-size: 18px;
  margin-top: 10px;
}

/* 左上角控制區 */
.top-left-controls {
  position: absolute;
  top: 20px;
  left: 20px;
  pointer-events: auto;
  z-index: 100;
  .back-btn {
    display: block;
    width: 100%;
    padding: 12px 16px;
    text-align: center;
    background: #e6be9154;
    border-radius: 100px;
    color: #752f11;
    font-size: 16px;
    text-decoration: none;
    transition: transform 0.1s, box-shadow 0.1s;
    &:hover {
      background: #e6be917a;
    }
    i {
      margin-right: 8px;
    }
  }
}

/* 左下角控制區 (RESET) */
.bottom-left-controls {
  position: absolute;
  bottom: 20px;
  left: 20px;
  pointer-events: auto;
}

/* 右下角控制區 */
.bottom-right-controls {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: flex;
  gap: 8px;
  pointer-events: auto;
  align-items: flex-end;
}

.circle-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 5px solid #725349;
  background: #f2c94c;
  color: #725349;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 4px 0 #72534935;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: transform 0.1s, box-shadow 0.1s;
  line-height: 1.2;
  &:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
  }
  &.mix {
    background: #4d9bea;
    color: white;
  }
  &.restart {
    background: #fff;
    color: #725349;
  }
  &.pick {
    background: #e05a47;
    color: white;
    width: 80px;
    height: 80px;
    z-index: 10;
  }
}

/* --- Modal 通用淡入淡出設定 --- */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(114, 83, 73, 0.6);
  /* 重複斜線 */
  background: linear-gradient(
    45deg,
    rgba(114, 83, 73, 0.5) 25%,
    rgba(130, 97, 87, 0.5) 0,
    rgba(130, 97, 87, 0.5) 50%,
    rgba(114, 83, 73, 0.5) 0,
    rgba(114, 83, 73, 0.5) 75%,
    rgba(130, 97, 87, 0.5) 0
  );
  background-size: 120px 120px;
  backdrop-filter: blur(3px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;

  /* 預設狀態 (隱藏) */
  opacity: 0;
  visibility: hidden;

  /* 
  淡出邏輯: 
  opacity 花 0.2s 變透明
  visibility 延遲 0.2s 後才變 hidden (確保淡出動畫播完)
  */
  transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}

.modal-overlay.show {
  /* 顯示狀態 */
  opacity: 1;
  visibility: visible;

  /* 
  淡入邏輯:
  opacity 花 0.2s 變不透明
  visibility 不需要延遲，馬上變 visible
  */
  transition: opacity 0.2s ease, visibility 0s linear 0s;
}

.modal-content {
  background: #f6f3eb;
  border: 5px solid #725349;
  border-radius: 20px;
  width: 380px;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-content.small {
  width: 320px;
  padding: 20px;
  text-align: center;
}
.modal-content.small h3 {
  color: #725349;
  font-size: 20px;
  margin: 10px 0 20px 0;
}
.modal-content.large {
  height: 550px;
  max-height: 90vh;
}

.tabs-header {
  display: flex;
  border-bottom: 5px solid #725349;
  background: #e6e1d6;
}

.tab-btn {
  flex: 1;
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  color: #725349;
  background: transparent;
  border: none;
  font-size: 18px;
  background: #fff;
  transition: background 0.2s;
  &.active {
    background: #f2c94c;
    color: #725349;
  }

  &:first-child {
    border-right: 5px solid #725349;
  }
}

.tabs-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  position: relative;
}

.tab-pane {
  display: none;
  height: 100%;
  flex-direction: column;
}

.tab-pane.active {
  display: flex;
}

.item-list {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow-y: auto;
  flex: 1;

  /* 自訂卷軸樣式 */
  scrollbar-width: thin;
  scrollbar-color: #72534944 transparent;

  min-height: 0;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;

  & li {
    padding: 8px 12px;
    border-bottom: 2px dashed #72534944;
    color: #725349;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background 0.1s;
  }

  & li:hover {
    background: rgba(0, 0, 0, 0.05);
  }

  & li.drawn {
    color: #72534966;
    text-decoration: line-through;
    text-decoration-thickness: 2px;
    opacity: 0.7;
  }
}

.color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 10px;
  border: 2px solid rgba(0, 0, 0, 0.1);
}

textarea {
  background: #fff;
  border: 5px solid #725349;
  border-radius: 10px;
  padding: 10px;
  font-size: 16px;
  resize: none;
  flex: 1;
  width: 100%;
  outline: none;
  color: #725349;
  line-height: 1.5;
  margin-bottom: 12px;

  /* 自訂卷軸樣式 */
  scrollbar-width: thin;
  scrollbar-color: #72534944 transparent;

  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.input-hint {
  font-size: 16px;
  color: #72534999;
  margin-bottom: 12px;
  i {
    margin-right: 8px;
  }
}

.checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  color: #725349;
  cursor: pointer;
}

input[type="checkbox"] {
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: #f6f3eb;
  border: 5px solid #725349;
  cursor: pointer;
  position: relative;
  margin: 0;

  &:checked::before {
    content: "\f00c";
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    color: #e05a47;
    font-size: 20px;
    position: absolute;
    top: 0px;
    left: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
  }
}

.modal-footer {
  padding: 16px 20px;
  border-top: 5px solid #725349;
  display: flex;
  gap: 12px;
}

.action-btn {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  font-size: 16px;
  cursor: pointer;
  border: 5px solid #725349;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.1);
}
.action-btn:active {
  transform: translateY(1px);
  box-shadow: none;
}

.btn-close {
  background: #fff;
  color: #725349;
}
.btn-restart {
  background: #e05a47;
  color: white;
}
.btn-yes {
  background: #e05a47;
  color: white;
}
.btn-no {
  background: #fff;
  color: #725349;
}

/* --- Result Overlay 淡入淡出設定 --- */
#result-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(246, 243, 235, 0.9);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  pointer-events: auto;
  z-index: 50;

  /* 預設 (隱藏) */
  opacity: 0;
  visibility: hidden;
  /* 淡出: Opacity 變 0 (0.2s), Visibility 延遲 0.2s 變 hidden */
  transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}

#result-overlay.show {
  /* 顯示 */
  opacity: 1;
  visibility: visible;
  /* 淡入: Opacity 變 1 (0.2s), Visibility 馬上變 visible */
  transition: opacity 0.2s ease, visibility 0s linear 0s;
}

.sphere-wrapper {
  opacity: 1;
  /* transform-origin: 50% 100%; */
}

#result-overlay.show .sphere-wrapper {
  animation: sphereEnter 0.6s forwards;
  animation-timing-function: cubic-bezier(0.32, 0, 0.42, 1.57);
}

@keyframes sphereEnter {
  0% {
    opacity: 0;
    transform: translateY(-300px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.sphere-display {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: linear-gradient(0deg, var(--bg-color) 50%, #ffffff 50%);
  border: 7px solid #725349;
  margin-bottom: 30px;
  position: relative;

  /* 左右晃動動畫 */
  animation: sway 2s ease-in-out infinite;

  &::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(0, 0, 0, 0.1);
    transform: translateY(-50%);
  }
}

@keyframes sway {
  0%,
  100% {
    transform: rotate(-10deg);
  }
  50% {
    transform: rotate(10deg);
  }
}

#result-text {
  font-size: 40px;
  color: #725349;
  text-align: center;
  max-width: 80%;
  margin-bottom: 30px;
  text-transform: uppercase;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#result-overlay.show #result-text {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 0.6s;
}

.close-result-btn {
  background: #e05a47;
  border: none;
  color: white;
  padding: 16px 40px;
  font-size: 20px;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.2);
  border: 7px solid #725349;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#result-overlay.show .close-result-btn {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 0.9s;
}

.close-result-btn:active {
  transform: translateY(3px);
  box-shadow: none;
}

body.hovering {
  cursor: pointer;
}
