/* ========== 全域重置 ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft JhengHei", "PingFang TC", sans-serif;
  background: #0a0a1a;
  color: #e0e0e0;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ========== 頂部暖光氛圍 ========== */
body::before {
  content: '';
  position: fixed;
  top: -120px;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 600px;
  background: radial-gradient(ellipse at center,
    rgba(160, 100, 220, 0.08) 0%,
    rgba(212, 175, 55, 0.04) 35%,
    transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ========== 星空背景 ========== */
#stars {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.star {
  position: absolute;
  background: #fff;
  border-radius: 50%;
  animation: twinkle var(--duration, 3s) ease-in-out infinite alternate;
  opacity: 0;
}

.glow-dot {
  position: absolute;
  width: 3px;
  height: 3px;
  background: rgba(212, 175, 55, 0.5);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(212, 175, 55, 0.3);
  animation: twinkle var(--duration, 4s) ease-in-out infinite alternate;
  opacity: 0;
}

@keyframes twinkle {
  0% { opacity: 0; }
  100% { opacity: var(--max-opacity, 0.5); }
}

/* ========== 側邊卦象裝飾 ========== */
.side-deco {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  opacity: 0.15;
  z-index: 0;
}

.side-deco.left { left: 24px; }
.side-deco.right { right: 24px; }

.deco-yang {
  width: 36px;
  height: 3px;
  background: #d4af37;
  border-radius: 2px;
}

.deco-yin {
  display: flex;
  gap: 8px;
}

.deco-yin span {
  width: 14px;
  height: 3px;
  background: #d4af37;
  border-radius: 2px;
}

/* ========== 主容器 ========== */
.container {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

/* ========== LOGO 區 ========== */
.logo-section {
  text-align: center;
  padding: 40px 0 28px;
}

.logo-icon {
  font-size: 56px;
  animation: spin 15s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.logo-title {
  font-size: 32px;
  font-weight: 800;
  background: linear-gradient(135deg, #d4af37, #f4d03f, #d4af37);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 10px;
  margin-bottom: 14px;
}

.logo-subtitle {
  font-size: 13px;
  color: #a09080;
  letter-spacing: 3px;
  margin-bottom: 12px;
  line-height: 1.8;
}

.logo-motto {
  font-size: 13px;
  color: #d4af37;
  letter-spacing: 4px;
  opacity: 0.6;
}

/* ========== 卡片 ========== */
.card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(212, 175, 55, 0.12);
  border-radius: 16px;
  padding: 28px 22px;
  margin-bottom: 20px;
  backdrop-filter: blur(8px);
}

.card-header {
  text-align: center;
  margin-bottom: 8px;
}

.card-header h2 {
  font-size: 18px;
  color: #f0e6d3;
  font-weight: 600;
  line-height: 1.6;
}

.card-desc {
  text-align: center;
  font-size: 13px;
  color: #888;
  margin-bottom: 24px;
  line-height: 1.6;
}

/* ========== 表單 ========== */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 14px;
  color: #d4af37;
  margin-bottom: 8px;
  font-weight: 500;
}

.form-group select,
.form-group input,
.form-group textarea {
  width: 100%;
  padding: 13px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: #d0d0d0;
  font-size: 15px;
  outline: none;
  transition: border-color 0.3s;
  -webkit-appearance: none;
  appearance: none;
}

.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.form-group select:focus,
.form-group input:focus,
.form-group textarea:focus {
  border-color: rgba(212, 175, 55, 0.5);
}

.form-group select option {
  background: #1a1a2e;
  color: #e0e0e0;
}

.form-group textarea {
  resize: vertical;
  min-height: 100px;
  font-family: inherit;
  line-height: 1.6;
}

.form-group input::placeholder,
.form-group textarea::placeholder,
.form-group select:invalid {
  color: #555;
}

/* ========== 按鈕 ========== */
.btn-primary {
  display: block;
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, #b8960c, #d4af37, #f4d03f, #d4af37);
  color: #1a1a2e;
  border: none;
  border-radius: 10px;
  font-size: 17px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  letter-spacing: 4px;
  margin-top: 8px;
}

.btn-primary:hover {
  box-shadow: 0 4px 20px rgba(212, 175, 55, 0.4);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  display: block;
  width: 100%;
  padding: 14px;
  background: transparent;
  color: #d4af37;
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 20px;
  letter-spacing: 2px;
}

.btn-secondary:hover {
  background: rgba(212, 175, 55, 0.08);
  border-color: #d4af37;
}

/* ========== 銅錢區 ========== */
.coin-area {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin: 24px 0;
}

.coin {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: bold;
  background: linear-gradient(145deg, #c9a84c, #8b6914);
  color: #1a1a2e;
  border: 3px solid #d4af37;
  transition: transform 0.6s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.coin.flipping {
  animation: coinFlip 0.6s ease-in-out;
}

@keyframes coinFlip {
  0% { transform: rotateY(0deg) scale(1); }
  50% { transform: rotateY(900deg) scale(1.2); }
  100% { transform: rotateY(1800deg) scale(1); }
}

.coin.heads {
  background: linear-gradient(145deg, #d4af37, #f4d03f);
  color: #1a1a2e;
  border-color: #f4d03f;
}

.coin.tails {
  background: linear-gradient(145deg, #5c4a1e, #3d2e0a);
  color: #d4af37;
  border-color: #8b6914;
}

/* ========== 擲卦提示 ========== */
.throw-result {
  text-align: center;
  color: #d4af37;
  font-size: 14px;
  min-height: 22px;
  margin-bottom: 16px;
}

.progress-info {
  text-align: center;
  color: #777;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ========== 卦象繪製 ========== */
.hexagram-build,
.hexagram-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
}

.line-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  animation: fadeInLine 0.4s ease-out;
}

@keyframes fadeInLine {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.line-label {
  font-size: 11px;
  color: #777;
  width: 28px;
  text-align: right;
  flex-shrink: 0;
}

.line-segment {
  height: 5px;
  border-radius: 3px;
}

.line-yang .line-segment {
  width: 110px;
  background: linear-gradient(90deg, #d4af37, #f4d03f);
  box-shadow: 0 0 6px rgba(212, 175, 55, 0.2);
}

.line-yin .line-segment {
  width: 48px;
  background: linear-gradient(90deg, #6a5acd, #8b7fdb);
  box-shadow: 0 0 6px rgba(106, 90, 205, 0.2);
}

.line-gap {
  width: 14px;
}

/* ========== 卦名 ========== */
.hex-name {
  text-align: center;
  font-size: 24px;
  font-weight: bold;
  color: #d4af37;
  margin-bottom: 8px;
  letter-spacing: 4px;
}

/* ========== 結果區 ========== */
.result-area {
  margin-top: 20px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  min-height: 80px;
  line-height: 1.8;
}

/* ========== 頁尾格言 ========== */
.footer-motto {
  text-align: center;
  padding: 28px 0 16px;
  color: #d4af37;
  font-size: 14px;
  letter-spacing: 4px;
  opacity: 0.6;
}

/* ========== 頁尾 ========== */
.footer {
  text-align: center;
  padding: 8px 0 20px;
}

.footer-email {
  font-size: 13px;
  color: #999;
  margin-bottom: 8px;
}

.footer-email a {
  color: #d4af37;
  text-decoration: none;
}

.footer-email a:hover {
  text-decoration: underline;
}

.footer-copy {
  font-size: 11px;
  color: #555;
  line-height: 1.6;
}

/* ========== 手機響應式 ========== */
@media (max-width: 600px) {
  .side-deco { opacity: 0.08; }
  .side-deco.left { left: 10px; }
  .side-deco.right { right: 10px; }
  .deco-yang { width: 24px; }
  .deco-yin span { width: 10px; }
  .deco-yin { gap: 4px; }
}

@media (max-width: 420px) {
  .container {
    padding: 16px 12px 32px;
  }
  .card {
    padding: 24px 16px;
  }
  .logo-title {
    font-size: 26px;
    letter-spacing: 6px;
  }
  .logo-subtitle {
    font-size: 11px;
    letter-spacing: 1px;
  }
  .logo-motto {
    font-size: 11px;
    letter-spacing: 2px;
  }
  .card-header h2 {
    font-size: 16px;
  }
  .coin {
    width: 54px;
    height: 54px;
    font-size: 18px;
  }
  .coin-area {
    gap: 16px;
  }
  .line-yang .line-segment {
    width: 90px;
  }
  .line-yin .line-segment {
    width: 38px;
  }
  .btn-primary {
    font-size: 16px;
    letter-spacing: 3px;
    padding: 14px;
  }
  .footer-motto {
    font-size: 12px;
    letter-spacing: 2px;
  }
  .footer-email { font-size: 12px; }
  .footer-copy { font-size: 10px; }
  .side-deco { display: none; }
}