@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;

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

  .modal-content-main {
    padding: 20px;
  }
}

.setting-row {
  margin-bottom: 20px;
  text-align: left;
  label {
    display: block;
    font-size: 18px;
    color: #725349;
    margin-bottom: 8px;
  }
  /* last-child */
  &:last-child {
    margin-bottom: 0;
  }
}

.range-inputs {
  display: flex;
  align-items: center;
  gap: 10px;
}

.range-inputs span {
  font-size: 20px;
  color: #725349;
}

input[type="number"] {
  background: #fff;
  border: 5px solid #725349;
  border-radius: 10px;
  padding: 12px;
  font-size: 18px;
  width: 100%;
  outline: none;
  color: #725349;
  text-align: center;
}

.checkbox-wrapper {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  color: #725349;
  cursor: pointer;
  margin-bottom: 0 !important;
}

input[type="checkbox"] {
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: #f6f3eb;
  border: 5px solid #725349;
  cursor: pointer;
  position: relative;
  margin: 0;
  flex-shrink: 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;
  margin-top: auto;
}

.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;
  transition: opacity 0.2s ease, visibility 0s linear 0.2s;
  &.show {
    /* 顯示 */
    opacity: 1;
    visibility: visible;
    /* 淡入: Opacity 變 1 (0.2s), Visibility 馬上變 visible */
    transition: opacity 0.2s ease, visibility 0s linear 0s;
  }

  h2 {
    font-size: 32px;
  }
}

#result-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  width: 100%;
  max-width: 800px; /* 限制最大寬度 */
  max-height: 50vh; /* 限制高度，超過則捲動 */
  overflow-y: auto; /* 垂直捲動 */
  margin-bottom: 20px;
  padding: 40px 10px;
  /* mask */
  mask-image: linear-gradient(
    to bottom,
    transparent 0px,
    black 40px,
    black calc(100% - 40px),
    transparent 100%
  );

  &::-webkit-scrollbar {
    display: none;
  }

  @media (max-width: 600px) {
    gap: 12px;
  }
}

.result-ball {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--bg-color);
  border: 6px solid #725349;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 40px;
  color: #725349;
  font-family: "Bungee", sans-serif;
  position: relative;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.15);

  /* 初始狀態 */
  opacity: 0;
  transform: translateY(50px) scale(0.8);
  animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  &.underline::after {
    content: "";
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 6px;
    background: #725349;
    border-radius: 2px;
  }

  @media (max-width: 600px) {
    width: 80px;
    height: 80px;
    font-size: 30px;
  }
}

@keyframes popIn {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* --- 結果頁底部的按鈕容器 --- */
.result-footer-controls {
  display: flex;
  gap: 15px; /* 按鈕之間的間距 */
  width: 340px; /* 稍微加寬以容納粗邊框的按鈕 */
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  margin-top: 10px;
}

/* 當結果頁顯示時，按鈕浮現 */
#result-overlay.show .result-footer-controls {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 0.5s; /* 等球跳出來後再顯示按鈕 */
}

/* 針對結果頁按鈕的特殊樣式*/
.result-footer-controls .action-btn {
  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;
}

/* 按下時的效果 */
.result-footer-controls .action-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

/* 取消按鈕 (白色) */
.result-footer-controls .btn-no {
  background: #fff;
  color: #725349;
}

/* 確認按鈕 (橘色) */
.result-footer-controls .btn-yes {
  background: #e05a47;
  color: #fff;
}

/* 移除舊的 .close-result-btn 樣式 (因為已經用上面的取代了) */
.close-result-btn {
  display: none;
}

body.hovering {
  cursor: pointer;
}
