* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  height: 100%;
  font-family: 'Microsoft JhengHei', 'Segoe UI', sans-serif;
  overflow-x: hidden;
  position: relative;
  /* GPU 加速優化 */
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}

body.theme-transitioning {
  transition: background-color 0.3s ease, color 0.3s ease;
}


/* 效能優化設定 */
/* 為所有動畫元素啟用GPU加速 */
*[class*="animation"], 
*[class*="animate"],
.stained-glass-bg,
.stars,
.clouds,
.title,
.glass-button,
.glass-input,
.button {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}

/* 日間彩繪玻璃背景 */
.day .stained-glass-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, 
    rgba(176, 224, 230, 0.6) 0%, 
    rgba(33, 150, 243, 0.5) 25%,
    rgba(156, 39, 176, 0.4) 50%,
    rgba(100, 149, 237, 0.5) 75%,
    rgba(103, 58, 183, 0.6) 100%);
  z-index: -2;
  animation: dayLightShift 20s ease-in-out infinite;
}

/* 夜間星光背景 */
.night .stained-glass-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(225deg, 
    rgba(25, 25, 112, 0.9) 0%, 
    rgba(75, 0, 130, 0.7) 25%,
    rgba(72, 61, 139, 0.6) 50%, 
    rgba(123, 104, 238, 0.5) 75%,
    rgba(25, 25, 112, 0.8) 100%);
  z-index: -2;
  animation: nightLightShift 25s ease-in-out infinite;
}

@keyframes dayLightShift {
  0%, 100% {
    opacity: 0.9;
    transform: translateZ(0);
  }
  50% {
    opacity: 1;
    transform: translateZ(0);
  }
}

@keyframes nightLightShift {
  0%, 100% {
    opacity: 0.8;
    transform: translateZ(0);
  }
  50% {
    opacity: 1;
    transform: translateZ(0);
  }
}

/* 星星效果 */
.stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.7;
    pointer-events: none;
}

/* 日間模式星星較淺 */
.day .stars {
    opacity: 0.2;
}

/* 夜間模式星星更亮 */
.night .stars {
    opacity: 0.8;
}

.star {
  position: absolute;
  width: 2px;
  height: 2px;
  background: white;
  border-radius: 50%;
  animation: twinkle 4s ease-in-out infinite;
}

@keyframes twinkle {
  0%, 100% {
    opacity: 0.3;
  }
  50% {
    opacity: 1;
  }
}

/* 雲朵效果 - 多矩形組合版本 */
.clouds {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  opacity: 0;
  transition: opacity 1s ease;
}

.day .clouds {
  opacity: 0.7;
}

.cloud {
  position: absolute;
  animation: cloudMove 40s linear infinite;
  transform: translateZ(0);
}

@keyframes cloudMove {
    0% { transform: translate3d(-150px, 0, 0); }
    100% { transform: translate3d(calc(100vw + 150px), 0, 0); }
}

/* 雲朵主體矩形 */
.cloud::before {
  content: '';
  position: absolute;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 25px;
}

/* 雲朵上層矩形 */
.cloud::after {
  content: '';
  position: absolute;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 20px;
}

/* 雲朵1 - 4個長矩形組成 */
.cloud1 {
  width: 140px;
  height: 45px;
  top: 8%;
  left: 8%;
  animation-duration: 50s;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 22px;
}

.cloud1::before {
  width: 110px;
  height: 35px;
  top: -18px;
  left: 15px;
}

.cloud1::after {
  width: 85px;
  height: 30px;
  top: -12px;
  right: 8px;
}

/* 雲朵1的額外長矩形 - 使用 box-shadow 創建 */
.cloud1 {
  box-shadow: 
    -8px 12px 0 -3px rgba(255, 255, 255, 0.28),
    35px 20px 0 -5px rgba(255, 255, 255, 0.22);
}

/* 雲朵2 - 3個長矩形組成 */
.cloud2 {
  width: 180px;
  height: 50px;
  top: 15%;
  right: 20%;
  animation-duration: 45s;
  animation-delay: -15s;
  background: rgba(255, 255, 255, 0.32);
  border-radius: 25px;
}

.cloud2::before {
  width: 140px;
  height: 40px;
  top: -20px;
  left: 20px;
}

.cloud2::after {
  width: 115px;
  height: 35px;
  top: -15px;
  right: 12px;
}

/* 雲朵2的額外長矩形 */
.cloud2 {
  box-shadow: 
    -12px 15px 0 -6px rgba(255, 255, 255, 0.25),
    50px 25px 0 -8px rgba(255, 255, 255, 0.2);
}

/* 雲朵3 - 4個長矩形組成 */
.cloud3 {
  width: 160px;
  height: 48px;
  top: 25%;
  left: 50%;
  animation-duration: 55s;
  animation-delay: -25s;
  background: rgba(255, 255, 255, 0.28);
  border-radius: 24px;
}

.cloud3::before {
  width: 125px;
  height: 38px;
  top: -19px;
  left: 18px;
}

.cloud3::after {
  width: 95px;
  height: 32px;
  top: -14px;
  right: 15px;
}

/* 雲朵3的額外長矩形 */
.cloud3 {
  box-shadow: 
    -10px 14px 0 -4px rgba(255, 255, 255, 0.24),
    40px 22px 0 -7px rgba(255, 255, 255, 0.19),
    75px 30px 0 -10px rgba(255, 255, 255, 0.15);
}

/* 玻璃紋理疊加 */
.glass-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(0deg, 
    transparent 0%, 
    rgba(255, 255, 255, 0.05) 50%, 
    transparent 100%);
  z-index: -1;
  opacity: 0.5;
}

.plus-info {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  top: 10px;
  position: fixed;
  z-index: 0;
  padding: 0.5rem 0.6rem;
}

.plus-buttons {
  display: flex;
  gap: 10px;
}

/* 主題切換按鈕 */
.button {
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.2);
  text-decoration: none;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 25px;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
}

.day .button {
  color: rgb(62, 59, 59);
}

.day .button span.day {
  display: none;
}

.night .button span.night {
  display: none;
}

.button:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

/* 主容器 */
.main-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  justify-items: center;
  align-items: center;
  padding: 0.5em;
}
.container {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  justify-items: center;
  align-items: center;
  padding: 1em;
  position: relative;
}

/* 標題 */
.title {
  display: flex;
  align-items: center;
  font-size: 3rem;
  font-weight: 700;
  color: white;
  text-align: center;
  margin-bottom: 10px;
  text-shadow:
    2px 2px 4px rgba(0, 0, 0, 0.8),
    0 0 20px rgba(255, 255, 255, 0.3);
  background: linear-gradient(45deg, #87CEEB, #4682B4, #4ECDC4, #45B7D1);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  background-clip: text;
  animation: gradientShift 6s ease-in-out infinite;
}

.title-icon {
  height: 1em;
  width: auto;
  margin-right: 0.5em;
}

.night .title {
  background: linear-gradient(45deg, #E6E6FA, #DDA0DD, #DA70D6, #BA55D3);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  background-clip: text;
}

.footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
}

@keyframes gradientShift {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

.subtitle {
  font-size: 18px;
  color: rgba(255, 255, 255, 0.9);
  text-align: center;
  margin-bottom: 2rem;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
}

.results-section {
  margin-top: 1rem;
  width: 100%;
  max-width: 800px;
}

/* 表單容器 */
.form-container {
  background: linear-gradient(145deg,
      rgba(255, 255, 255, 0.25) 0%,
      rgba(255, 255, 255, 0.1) 50%,
      rgba(0, 0, 0, 0.05) 100%);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 30px;
  padding: 1.5rem 2.5rem 1rem 2.5rem;
  box-shadow:
    0 25px 50px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  max-width: 800px;
  width: 100%;
}

.flex-row {
  display: flex;
  justify-content: center;
  text-align: center;
}

/* 整列輸入框容器 */
.input-group {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

/* 單個輸入框 */
.glass-input {
  width: 1.8em;
  height: 1.8em;
  font-size: 2.1rem;
  font-weight: 700;
  text-align: center;
  background: linear-gradient(145deg,
      rgba(255, 255, 255, 0.2) 0%,
      rgba(255, 255, 255, 0.1) 100%);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 15px;
  color: white;
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.1),
    0 4px 8px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
  font-family: 'Courier New', monospace;
  text-transform: uppercase;
}

.day .glass-input {
  color: black;
}

.glass-input:focus {
  outline: none;
  border: 2px solid rgba(255, 255, 255, 0.6);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.1),
    0 8px 20px rgba(255, 255, 255, 0.3),
    0 0 0 4px rgba(255, 255, 255, 0.1);
  background: linear-gradient(145deg,
      rgba(255, 255, 255, 0.3) 0%,
      rgba(255, 255, 255, 0.15) 100%);
  transform: scale(1.05);
}

/* 玻璃按鈕 */
.glass-button {
  position: relative;
  width: 100%;
  max-width: 15em;
  padding: 18px 30px;
  font-size: 18px;
  font-weight: 600;
  color: white;
  background: linear-gradient(145deg,
      rgba(255, 255, 255, 0.3) 0%,
      rgba(255, 255, 255, 0.1) 50%,
      rgba(0, 0, 0, 0.1) 100%);
  background-color: rgba(147, 51, 234, 0.7);
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 20px;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.3s ease;
  box-shadow:
    0 10px 30px rgba(147, 51, 234, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  user-select: none;
  font-family: inherit;
}

.night .glass-button {
  background-color: rgba(88, 73, 186, 0.7);
  box-shadow:
    0 10px 30px rgba(72, 61, 139, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
}

.glass-button:hover {
  transform: translate3d(0, -2px, 0);
  box-shadow:
    0 15px 40px rgba(147, 51, 234, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
  background-color: rgba(168, 85, 247, 0.8);
}

.night .glass-button:hover {
  background-color: rgba(123, 104, 238, 0.8);
  box-shadow:
    0 15px 40px rgba(72, 61, 139, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
}

.glass-button:active {
  transform: translate3d(0, 0, 0);
}

/* 點擊波紋效果 */
.glass-button::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: radial-gradient(circle,
      rgba(255, 255, 255, 0.6) 0%,
      rgba(255, 255, 255, 0.3) 50%,
      transparent 100%);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: all 0.3s ease;
  opacity: 0;
  pointer-events: none;
}

.glass-button:active::after {
  width: 400px;
  height: 400px;
  opacity: 1;
  transition: all 0.1s ease;
}

/* 光澤效果 */
.shine-overlay {
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg,
      transparent,
      rgba(255, 255, 255, 0.5),
      transparent);
  transition: left 0.6s ease;
}

.glass-button:hover .shine-overlay {
  left: 100%;
}

/* 時間顯示 */
.time-display {
  color: white;
  font-size: 14px;
  background: rgba(0, 0, 0, 0.3);
  padding: 10px 15px;
  border-radius: 20px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
  line-height: 1.4;
  max-width: 300px;
}

.hide {
  display: none;
}

/* 響應式設計 */
@media (max-width: 765px) {
  .container {
    padding: 0.5em;
  }

  .title {
    font-size: 2rem;
  }

  .subtitle {
    font-size: 1rem;
    margin-bottom: 1rem;
  }

  .plus-info {
    position: initial;
    flex-direction: column;
    gap: 10px;
    align-items: center;
  }

  .time-display {
    font-size: 0.8rem;
    padding: 0.25rem 0.8rem;
    border-radius: 10px;
  }

  .form-container {
    padding: 0.5rem;
    margin-bottom: 5px;
    max-width: 100%;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  }

  .input-group {
    gap: 0.25rem;
    margin-top: 1rem;
    margin-bottom: 1rem;
  }

  .glass-input {
    width: 1.56em;
    height: 1.56em;
    border-radius: 5px;
    font-size: 20px;
  }

  .glass-button {
    padding: 15px 25px;
    font-size: 16px;
  }

  .mobile-hide {
    display: none;
  }
}

/* 在低效能設備上禁用複雜特效 */
@media (prefers-reduced-motion: reduce) {
    .stars,
    .clouds {
        display: none !important;
    }
    
    .stained-glass-bg {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
        animation: none !important;
    }
    
    .glass-input,
    .glass-button,
    .form-container,
    .button,
    .time-display {
        background: rgba(255, 255, 255, 0.9) !important;
    }
    
    .title {
        animation: none !important;
        background: linear-gradient(45deg, #87CEEB, #4682B4) !important;
        -webkit-background-clip: text !important;
        background-clip: text !important;
    }
    
    * {
        animation-duration: 0.1s !important;
        transition-duration: 0.1s !important;
    }
}
