/* ============================================
   命盤暴擊｜Bazi Impact — 樣式表
   風格：高對比超強視覺衝擊 × 數位新野獸派 × 普普藝術
   ============================================ */

/* ========== CSS 變數 ========== */
:root {
  --black: #000000;
  --white: #FFFFFF;
  --yellow: #FFE500;
  --pink: #FF2D7B;
  --blue: #00D4FF;
  --green: #00FF41;
  --grey: #333333;
  --dark-grey: #1a1a1a;
  /* 五行色 */
  --wood: #00FF41;
  --fire: #FF2D7B;
  --earth: #FFE500;
  --metal: #FFFFFF;
  --water: #00D4FF;
  /* 字體 */
  --font-serif: 'Noto Serif TC', 'Georgia', serif;
}

/* ========== 基礎重置 ========== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: auto; /* 刻意不用 smooth，保留重量感 */
}

body {
  font-family: var(--font-serif);
  background: var(--black);
  color: var(--white);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--yellow);
  color: var(--black);
}

/* ========== 畫面切換 ========== */
.screen {
  display: none;
  min-height: 100vh;
  position: relative;
}
.screen.active {
  display: flex;
  flex-direction: column;
}

/* ========== 閃光轉場 ========== */
.flash-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: var(--white);
  opacity: 0;
  pointer-events: none;
  z-index: 9999;
  transition: none;
}
.flash-overlay.flash-active {
  animation: flashBang 0.35s ease-out forwards;
}
@keyframes flashBang {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* ========== 雜訊紋理層 ========== */
.noise-layer {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 9998;
  opacity: 0.04;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255,255,255,0.03) 2px, rgba(255,255,255,0.03) 4px);
}

/* ========================================
   開場畫面（Landing）
   ======================================== */
#screen-landing {
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  overflow: hidden;
}

.landing-inner {
  text-align: center;
  z-index: 2;
  padding: 2rem;
}

.landing-author {
  font-size: clamp(0.8rem, 2vw, 1rem);
  letter-spacing: 0.5em;
  text-transform: uppercase;
  color: var(--yellow);
  margin-bottom: 1rem;
  animation: flicker 3s infinite;
}

/* 主標題：巨大、侵略感 */
.main-title {
  font-size: clamp(4rem, 18vw, 14rem);
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: -0.04em;
  margin-bottom: 1.5rem;
  position: relative;
  display: inline-block;
}

/* 故障文字效果 */
.glitch {
  position: relative;
  animation: glitchShift 4s infinite;
}
.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}
.glitch::before {
  color: var(--pink);
  z-index: -1;
  animation: glitchTop 3s infinite linear alternate-reverse;
}
.glitch::after {
  color: var(--blue);
  z-index: -2;
  animation: glitchBottom 2.5s infinite linear alternate-reverse;
}

@keyframes glitchShift {
  0%, 90%, 100% { transform: translate(0); }
  92% { transform: translate(-3px, 2px); }
  94% { transform: translate(3px, -2px); }
  96% { transform: translate(-2px, -1px); }
  98% { transform: translate(2px, 1px); }
}
@keyframes glitchTop {
  0%, 85%, 100% { clip-path: inset(0 0 90% 0); transform: translate(0); }
  87% { clip-path: inset(20% 0 50% 0); transform: translate(-5px, -2px); }
  89% { clip-path: inset(60% 0 10% 0); transform: translate(5px, 2px); }
  91% { clip-path: inset(0 0 80% 0); transform: translate(-3px, 1px); }
}
@keyframes glitchBottom {
  0%, 80%, 100% { clip-path: inset(90% 0 0 0); transform: translate(0); }
  82% { clip-path: inset(40% 0 30% 0); transform: translate(4px, 2px); }
  84% { clip-path: inset(10% 0 60% 0); transform: translate(-4px, -1px); }
  86% { clip-path: inset(70% 0 5% 0); transform: translate(2px, -2px); }
}

/* 宣言文字 */
.manifesto {
  font-size: clamp(1.5rem, 5vw, 3.5rem);
  font-weight: 900;
  letter-spacing: 0.15em;
  color: var(--yellow);
  margin-bottom: 0.8rem;
}

.sub-manifesto {
  font-size: clamp(0.9rem, 2.5vw, 1.3rem);
  color: rgba(255,255,255,0.6);
  line-height: 1.8;
  margin-bottom: 3rem;
}

/* CTA 按鈕 */
.cta-button {
  display: inline-block;
  padding: 1rem 3rem;
  font-family: var(--font-serif);
  font-size: clamp(1rem, 2.5vw, 1.4rem);
  font-weight: 700;
  color: var(--black);
  background: var(--yellow);
  border: 4px solid var(--yellow);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  position: relative;
  overflow: hidden;
  transition: all 0.15s;
}
.cta-button:hover {
  background: transparent;
  color: var(--yellow);
  box-shadow: 0 0 30px rgba(255, 229, 0, 0.4);
}
.cta-button:active {
  transform: scale(0.96);
}

/* 裝飾斜線文字 */
.deco-text {
  position: absolute;
  font-size: clamp(3rem, 10vw, 8rem);
  font-weight: 900;
  opacity: 0.04;
  white-space: nowrap;
  pointer-events: none;
  z-index: 1;
}
.deco-left {
  bottom: 5%;
  left: -5%;
  transform: rotate(-90deg);
  transform-origin: left bottom;
}
.deco-right {
  top: 10%;
  right: -2%;
  transform: rotate(90deg);
  transform-origin: right top;
}

/* ========================================
   生日輸入畫面
   ======================================== */
#screen-input {
  justify-content: center;
  align-items: center;
}

.input-step {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  width: 100%;
  text-align: center;
  animation: stepFadeIn 0.4s ease-out;
}
.input-step.active {
  display: flex;
}

@keyframes stepFadeIn {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

.step-indicator {
  font-size: 0.85rem;
  letter-spacing: 0.3em;
  color: rgba(255,255,255,0.3);
  margin-bottom: 2rem;
}

.step-question {
  font-size: clamp(2rem, 7vw, 5rem);
  font-weight: 900;
  line-height: 1.1;
  margin-bottom: 2.5rem;
}

/* 強調色 */
.accent-yellow { color: var(--yellow); }
.accent-pink   { color: var(--pink); }
.accent-blue   { color: var(--blue); }

/* 大型輸入框 */
.big-input {
  font-family: var(--font-serif);
  font-size: clamp(2.5rem, 8vw, 5rem);
  font-weight: 900;
  color: var(--white);
  background: transparent;
  border: none;
  border-bottom: 4px solid var(--yellow);
  text-align: center;
  width: 280px;
  max-width: 80vw;
  padding: 0.5rem 0;
  outline: none;
  caret-color: var(--yellow);
  -moz-appearance: textfield;
}
.big-input::-webkit-outer-spin-button,
.big-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.big-input::placeholder {
  color: rgba(255,255,255,0.15);
  font-size: 0.5em;
}
.big-input:focus {
  border-bottom-color: var(--pink);
}
.big-input.shake {
  animation: inputShake 0.4s ease;
}
@keyframes inputShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* 確認按鈕（步驟內） */
.step-btn {
  margin-top: 2rem;
  padding: 0.8rem 2.5rem;
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--white);
  background: transparent;
  border: 3px solid var(--pink);
  cursor: pointer;
  letter-spacing: 0.15em;
  transition: all 0.15s;
}
.step-btn:hover {
  background: var(--pink);
  color: var(--black);
}

.step-hint {
  margin-top: 1.5rem;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.35);
}

/* 選擇格子（月份 / 日期 / 時辰） */
.select-grid {
  display: grid;
  gap: 10px;
  max-width: 600px;
  width: 90vw;
}
.month-grid { grid-template-columns: repeat(4, 1fr); }
.day-grid   { grid-template-columns: repeat(7, 1fr); }
.hour-grid  { grid-template-columns: repeat(3, 1fr); }
.zi-grid    { grid-template-columns: repeat(2, 1fr); max-width: 400px; }

.grid-btn {
  font-family: var(--font-serif);
  font-size: clamp(1rem, 2.5vw, 1.3rem);
  font-weight: 700;
  color: var(--white);
  background: var(--dark-grey);
  border: 2px solid var(--grey);
  padding: 0.8rem 0.5rem;
  cursor: pointer;
  transition: all 0.12s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.grid-btn small {
  font-size: 0.6em;
  font-weight: 400;
  color: rgba(255,255,255,0.4);
}
.grid-btn:hover {
  border-color: var(--yellow);
  color: var(--yellow);
  background: rgba(255,229,0,0.08);
}
.grid-btn:active {
  transform: scale(0.93);
}
.grid-btn.selected {
  border-color: var(--yellow);
  background: var(--yellow);
  color: var(--black);
}
.grid-btn.unknown-btn {
  grid-column: 1 / -1;
  border-color: rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.5);
  font-size: 0.9rem;
}
.grid-btn.unknown-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
}

/* 性別按鈕 */
.gender-group {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}
.gender-btn {
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 900;
  color: var(--white);
  background: transparent;
  border: 3px solid var(--white);
  padding: 1rem 2.5rem;
  cursor: pointer;
  transition: all 0.12s;
  min-width: 120px;
}
.gender-btn:hover {
  border-color: var(--pink);
  color: var(--pink);
  box-shadow: 0 0 20px rgba(255,45,123,0.3);
}
.gender-btn:active {
  transform: scale(0.94);
}
.skip-btn {
  font-size: clamp(1rem, 2.5vw, 1.3rem);
  border-color: rgba(255,255,255,0.3);
  color: rgba(255,255,255,0.5);
  padding: 0.8rem 2rem;
}
.skip-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
  box-shadow: 0 0 15px rgba(0,212,255,0.2);
}

/* ========================================
   載入畫面
   ======================================== */
#screen-loading {
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

.loading-inner {
  text-align: center;
  padding: 2rem;
}

.loading-lines {
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
}

.loading-line {
  font-size: clamp(1rem, 3vw, 1.6rem);
  font-weight: 700;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.5s ease-out;
}
.loading-line.visible {
  opacity: 1;
  transform: translateY(0);
}
.loading-line.glow-yellow { color: var(--yellow); text-shadow: 0 0 20px rgba(255,229,0,0.6); }
.loading-line.glow-pink   { color: var(--pink);   text-shadow: 0 0 20px rgba(255,45,123,0.6); }
.loading-line.glow-blue   { color: var(--blue);   text-shadow: 0 0 20px rgba(0,212,255,0.6); }
.loading-line.glow-white  { color: var(--white);  text-shadow: 0 0 30px rgba(255,255,255,0.8); }

.loading-spinner {
  margin-top: 2rem;
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--yellow);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-inline: auto;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========================================
   結果報告畫面
   ======================================== */
#screen-result {
  display: none;
  min-height: 100vh;
}
#screen-result.active {
  display: block;
}

.result-inner {
  max-width: 800px;
  margin: 0 auto;
  padding: 3rem 1.5rem 5rem;
}

/* 出生資訊 */
.birth-info {
  text-align: center;
  font-size: 0.9rem;
  color: rgba(255,255,255,0.4);
  letter-spacing: 0.1em;
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

/* 四柱八字 */
.pillars-section {
  margin-bottom: 4rem;
}

.section-label {
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  font-weight: 900;
  text-align: center;
  letter-spacing: 0.2em;
  margin-bottom: 2rem;
  color: var(--yellow);
}

.pillars-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  max-width: 560px;
  margin: 0 auto;
}

.pillar-card {
  text-align: center;
  border: 2px solid var(--grey);
  padding: 1.2rem 0.5rem;
  position: relative;
  background: var(--dark-grey);
  animation: pillarReveal 0.6s ease-out backwards;
}
.pillar-card:nth-child(1) { animation-delay: 0.1s; }
.pillar-card:nth-child(2) { animation-delay: 0.25s; }
.pillar-card:nth-child(3) { animation-delay: 0.4s; border-color: var(--yellow); } /* 日柱特別強調 */
.pillar-card:nth-child(4) { animation-delay: 0.55s; }

@keyframes pillarReveal {
  from { opacity: 0; transform: translateY(20px) scale(0.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.pillar-label {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.4);
  letter-spacing: 0.15em;
  margin-bottom: 0.8rem;
}

.pillar-gan {
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 900;
  line-height: 1;
  margin-bottom: 0.4rem;
}

.pillar-zhi {
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 900;
  line-height: 1;
  margin-bottom: 0.6rem;
}

.pillar-element {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  padding: 2px 8px;
  display: inline-block;
}

/* 五行顏色 */
.wx-wood  { color: var(--wood); }
.wx-fire  { color: var(--fire); }
.wx-earth { color: var(--earth); }
.wx-metal { color: var(--metal); }
.wx-water { color: var(--water); }

.wx-wood-bg  { border-color: var(--wood); }
.wx-fire-bg  { border-color: var(--fire); }
.wx-earth-bg { border-color: var(--earth); }
.wx-metal-bg { border-color: var(--metal); }
.wx-water-bg { border-color: var(--water); }

/* 身強身弱區塊 */
.strength-section {
  margin-bottom: 4rem;
  text-align: center;
}

.strength-bar-wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: 500px;
  margin: 0 auto 1.5rem;
}

.bar-label-left,
.bar-label-right {
  font-size: 0.8rem;
  font-weight: 700;
  color: rgba(255,255,255,0.5);
  white-space: nowrap;
  min-width: 40px;
}

.strength-bar {
  flex: 1;
  height: 12px;
  background: var(--dark-grey);
  border: 1px solid var(--grey);
  position: relative;
  overflow: hidden;
}

.strength-fill {
  height: 100%;
  width: 0%;
  transition: width 1.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.strength-marker {
  position: absolute;
  top: -6px;
  width: 4px;
  height: 24px;
  background: var(--white);
  transform: translateX(-50%);
  left: 50%;
  transition: left 1.5s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 0 10px rgba(255,255,255,0.5);
}

.strength-result {
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 900;
  letter-spacing: 0.1em;
}

/* 喜用神 / 忌神 */
.favorable-section {
  margin-bottom: 4rem;
}

.fav-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  max-width: 650px;
  margin: 0 auto;
}

.fav-card {
  border: 2px solid;
  padding: 1.5rem 1rem;
  text-align: center;
  background: rgba(255,255,255,0.02);
  animation: cardReveal 0.5s ease-out backwards;
}

@keyframes cardReveal {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

.fav-card-label {
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  margin-bottom: 0.5rem;
  opacity: 0.6;
}

.fav-card-element {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  font-weight: 900;
}

.fav-card-desc {
  font-size: 0.8rem;
  margin-top: 0.5rem;
  color: rgba(255,255,255,0.5);
  line-height: 1.6;
}

/* 報告章節 */
.report-chapters {
  margin-top: 3rem;
}

.report-chapter {
  margin-bottom: 3.5rem;
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}
.report-chapter.visible {
  opacity: 1;
  transform: translateY(0);
}

.chapter-divider {
  width: 60px;
  height: 3px;
  margin-bottom: 1.5rem;
}

.chapter-number {
  font-size: 0.75rem;
  letter-spacing: 0.3em;
  color: rgba(255,255,255,0.3);
  margin-bottom: 0.5rem;
}

.chapter-title {
  font-size: clamp(1.3rem, 3.5vw, 2rem);
  font-weight: 900;
  margin-bottom: 1.5rem;
  line-height: 1.3;
}

.chapter-body {
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  line-height: 2;
  color: rgba(255,255,255,0.82);
  text-align: justify;
}

/* 報告章節不同的強調色 */
.chapter-accent-yellow .chapter-divider { background: var(--yellow); }
.chapter-accent-yellow .chapter-title   { color: var(--yellow); }
.chapter-accent-pink .chapter-divider   { background: var(--pink); }
.chapter-accent-pink .chapter-title     { color: var(--pink); }
.chapter-accent-blue .chapter-divider   { background: var(--blue); }
.chapter-accent-blue .chapter-title     { color: var(--blue); }
.chapter-accent-white .chapter-divider  { background: var(--white); }
.chapter-accent-white .chapter-title    { color: var(--white); }
.chapter-accent-green .chapter-divider  { background: var(--green); }
.chapter-accent-green .chapter-title    { color: var(--green); }

/* 大師 CTA 區塊 */
.master-cta {
  text-align: center;
  margin: 5rem 0 3rem;
  padding: 3rem 1.5rem;
  border: 2px solid var(--yellow);
  background: rgba(255, 229, 0, 0.03);
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}
.master-cta.visible {
  opacity: 1;
  transform: translateY(0);
}
.cta-divider {
  width: 80px;
  height: 3px;
  background: var(--yellow);
  margin: 0 auto 2rem;
}
.cta-heading {
  font-size: clamp(1.3rem, 3.5vw, 2rem);
  font-weight: 900;
  color: var(--yellow);
  margin-bottom: 1.5rem;
  letter-spacing: 0.05em;
}
.cta-text {
  font-size: clamp(0.85rem, 2vw, 1rem);
  color: rgba(255,255,255,0.55);
  line-height: 2;
  margin-bottom: 1.5rem;
}
.cta-highlight {
  font-size: clamp(1.1rem, 2.8vw, 1.5rem);
  font-weight: 900;
  color: var(--white);
  line-height: 1.8;
  margin-bottom: 1rem;
}
.cta-highlight strong {
  color: var(--yellow);
  font-size: 1.15em;
}
.cta-sub {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.4);
  letter-spacing: 0.1em;
}

/* 重新計算區 */
.restart-wrap {
  text-align: center;
  margin: 5rem 0 3rem;
}
.restart-btn {
  font-size: 1rem;
  padding: 0.9rem 2.5rem;
}

/* 底部署名 */
.footer-credit {
  text-align: center;
  padding: 3rem 0 2rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 0.8rem;
  color: rgba(255,255,255,0.25);
  letter-spacing: 0.15em;
}
.credit-author {
  margin-top: 0.3rem;
  color: var(--yellow);
  opacity: 0.5;
}

/* report-section 通用動畫 */
.report-section {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.7s ease-out, transform 0.7s ease-out;
}
.report-section.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ========== 共用動畫 ========== */
@keyframes flicker {
  0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% { opacity: 1; }
  20%, 22%, 24%, 55% { opacity: 0.4; }
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 rgba(255,229,0,0); }
  50% { box-shadow: 0 0 30px rgba(255,229,0,0.3); }
}

/* ========== 響應式設計 ========== */
@media (max-width: 600px) {
  .month-grid { grid-template-columns: repeat(3, 1fr); }
  .hour-grid  { grid-template-columns: repeat(2, 1fr); }
  .day-grid   { grid-template-columns: repeat(7, 1fr); gap: 6px; }
  .day-grid .grid-btn { padding: 0.6rem 0.2rem; font-size: 0.9rem; }

  .pillars-row { gap: 8px; }
  .pillar-card { padding: 1rem 0.3rem; }
  .pillar-gan, .pillar-zhi { font-size: 1.8rem; }

  .fav-cards { grid-template-columns: 1fr; }

  .gender-group { flex-direction: column; align-items: center; }
  .gender-btn { width: 200px; }
}

@media (min-width: 1200px) {
  .result-inner {
    max-width: 880px;
    padding: 4rem 2rem 6rem;
  }
  .chapter-body {
    font-size: 1.15rem;
  }
}
