/* ==========================================================================
   Chinese Modern Dark-Gold Luxury Aesthetic Design System (国学暗金风)
   ========================================================================== */

:root {
  --bg-primary: #0d0a12;
  --bg-secondary: #171320;
  --bg-card: rgba(30, 24, 42, 0.75);
  --bg-card-hover: rgba(45, 36, 64, 0.85);

  --accent-gold: #D4AF37;
  --accent-gold-light: #F3E5AB;
  --accent-gold-bright: #FFD700;
  --accent-red: #8B0000;
  --accent-red-bright: #E63946;
  --accent-green: #2A9D8F;
  --accent-purple: #6B2D5C;

  --text-main: #F4E8C1;
  --text-muted: #A89F91;
  --text-dark: #121212;

  --border-gold: rgba(212, 175, 55, 0.35);
  --border-gold-glow: rgba(212, 175, 55, 0.75);
  --shadow-gold: 0 4px 20px rgba(212, 175, 55, 0.15);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.5);

  --font-serif: "Noto Serif SC", "Songti SC", "STSong", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 50% 0%, rgba(139, 0, 0, 0.25), transparent 70%),
    radial-gradient(circle at 80% 80%, rgba(212, 175, 55, 0.08), transparent 50%);
  background-attachment: fixed;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13, 10, 18, 0.9);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-gold);
  padding: 12px 24px;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-badge {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--accent-red), #4A0000);
  border: 1.5px solid var(--accent-gold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 22px;
  color: var(--accent-gold-bright);
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.4);
}

.title-text {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #FFF, var(--accent-gold-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle-text {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.nav-scroll {
  max-width: 1200px;
  margin: 0 auto;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 10px 0;
}
.nav-scroll::-webkit-scrollbar { display: none; }

.nav-tabs {
  display: flex;
  gap: 8px;
  padding: 4px;
  background: rgba(23, 19, 32, 0.8);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-gold);
}

.nav-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-btn:hover {
  color: var(--text-main);
  background: rgba(212, 175, 55, 0.1);
}

.nav-btn.active {
  background: linear-gradient(135deg, var(--accent-red), #600000);
  color: var(--accent-gold-bright);
  font-weight: 600;
  box-shadow: 0 2px 12px rgba(139, 0, 0, 0.6);
  border: 1px solid var(--accent-gold);
}

/* ==========================================================================
   Main Layout & Portal Cards
   ========================================================================== */

.main-content {
  max-width: 1200px;
  margin: 20px auto 60px;
  padding: 0 16px;
}

.tab-panel {
  display: none;
  animation: fadeIn 0.4s ease-out;
}

.tab-panel.active {
  display: block;
}

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

/* Daily Almanac Header Banner */
.almanac-banner {
  background: linear-gradient(135deg, rgba(40, 20, 25, 0.9), rgba(20, 15, 30, 0.9));
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.almanac-banner::before {
  content: "福";
  position: absolute;
  right: -20px;
  bottom: -30px;
  font-family: var(--font-serif);
  font-size: 160px;
  color: rgba(212, 175, 55, 0.04);
  pointer-events: none;
}

.date-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
}

.solar-lunar-title {
  font-family: var(--font-serif);
  font-size: 24px;
  color: var(--accent-gold-bright);
  font-weight: 700;
}

.ganzhi-info {
  font-size: 15px;
  color: var(--text-main);
  margin-top: 4px;
}

.calendar-btn {
  background: linear-gradient(135deg, var(--accent-gold), #997A15);
  color: #121212;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(212, 175, 55, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
}

.calendar-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(212, 175, 55, 0.5);
}

.yi-ji-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  background: rgba(10, 8, 14, 0.6);
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.badge-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.badge-tag {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 14px;
  flex-shrink: 0;
}

.badge-yi { background: var(--accent-green); color: #FFF; }
.badge-ji { background: var(--accent-red-bright); color: #FFF; }

.badge-list {
  font-size: 14px;
  color: var(--text-main);
  line-height: 1.8;
}

/* Feature Grid Cards */
.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-lg);
  padding: 24px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 170px;
  position: relative;
  overflow: hidden;
}

.feature-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-gold-bright);
  transform: translateY(-4px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.6), 0 0 15px rgba(212, 175, 55, 0.2);
}

.card-icon {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-family: var(--font-serif);
  font-weight: bold;
  margin-bottom: 12px;
  border: 1px solid var(--border-gold);
}

.bg-red { background: linear-gradient(135deg, #8B0000, #400000); color: var(--accent-gold-bright); }
.bg-gold { background: linear-gradient(135deg, #B8860B, #5C4305); color: #FFF; }
.bg-blue { background: linear-gradient(135deg, #1E3A8A, #0F1D45); color: #93C5FD; }
.bg-purple { background: linear-gradient(135deg, #4C1D95, #260E4A); color: #DDD6FE; }
.bg-green { background: linear-gradient(135deg, #065F46, #033023); color: #A7F3D0; }
.bg-pink { background: linear-gradient(135deg, #9D174D, #4F0B27); color: #FBCFE8; }

.card-title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
}

.card-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ==========================================================================
   Module 1: Yijing Dayan Divination (高岛易断)
   ========================================================================== */

.divine-box {
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-lg);
  padding: 30px;
  text-align: center;
  max-width: 800px;
  margin: 0 auto;
}

.divine-title {
  font-family: var(--font-serif);
  font-size: 26px;
  color: var(--accent-gold-bright);
  margin-bottom: 8px;
}

.divine-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.sticks-stage {
  height: 180px;
  background: rgba(10, 8, 14, 0.8);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  margin-bottom: 24px;
}

.stick-anim {
  width: 4px;
  height: 100px;
  background: linear-gradient(to bottom, #D4AF37, #8B5A2B);
  margin: 0 4px;
  border-radius: 2px;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-red), #5A0000);
  color: var(--accent-gold-bright);
  border: 1px solid var(--accent-gold);
  padding: 12px 36px;
  font-size: 16px;
  font-weight: 700;
  border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(139, 0, 0, 0.5);
  transition: all 0.3s;
}

.btn-primary:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 25px rgba(212, 175, 55, 0.4);
}

/* Hexagram Result Display */
.hexagram-container {
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 30px;
}

.hexagram-card {
  flex: 1;
  min-width: 280px;
  background: rgba(15, 12, 22, 0.8);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-md);
  padding: 20px;
}

.hex-title {
  font-family: var(--font-serif);
  font-size: 20px;
  color: var(--accent-gold-bright);
  margin-bottom: 16px;
}

.lines-stack {
  display: flex;
  flex-direction: column-reverse; /* Bottom line is line 1 */
  gap: 8px;
  margin-bottom: 16px;
}

.yao-line {
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.yang-bar {
  width: 140px;
  height: 14px;
  background: linear-gradient(to right, #D4AF37, #FFD700);
  border-radius: 3px;
}

.yin-bars {
  width: 140px;
  height: 14px;
  display: flex;
  justify-content: space-between;
}

.yin-part {
  width: 62px;
  height: 14px;
  background: linear-gradient(to right, #D4AF37, #E5C158);
  border-radius: 3px;
}

.yao-line.changing .yang-bar,
.yao-line.changing .yin-part {
  background: linear-gradient(to right, var(--accent-red-bright), #FF6B6B) !important;
  box-shadow: 0 0 10px rgba(255, 107, 107, 0.8);
}

/* ==========================================================================
   Module 2: Fengshui Compass (风水罗盘)
   ========================================================================== */

.compass-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.compass-stage {
  position: relative;
  padding: 10px;
  background: radial-gradient(circle, rgba(30, 20, 15, 0.8), rgba(10, 5, 5, 0.95));
  border: 2px solid var(--accent-gold);
  border-radius: 50%;
  box-shadow: 0 0 40px rgba(212, 175, 55, 0.25);
}

.compass-readout {
  background: rgba(20, 15, 25, 0.8);
  border: 1px solid var(--border-gold);
  padding: 16px 28px;
  border-radius: var(--radius-md);
  text-align: center;
}

.degree-val {
  font-family: var(--font-serif);
  font-size: 32px;
  color: var(--accent-gold-bright);
  font-weight: bold;
}

.mountain-val {
  font-size: 18px;
  color: var(--text-main);
  margin-top: 4px;
}

/* ==========================================================================
   Module 3: Bazi Four Pillars (八字排盘) & Marriage Matching
   ========================================================================== */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 13px;
  color: var(--text-muted);
}

.form-control {
  background: rgba(10, 8, 15, 0.8);
  border: 1px solid var(--border-gold);
  color: var(--text-main);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
}

.form-control:focus {
  border-color: var(--accent-gold-bright);
  box-shadow: 0 0 8px rgba(212, 175, 55, 0.4);
}

.bazi-table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  background: rgba(15, 12, 22, 0.8);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.bazi-table th, .bazi-table td {
  padding: 12px;
  text-align: center;
  border: 1px solid rgba(212, 175, 55, 0.15);
}

.bazi-table th {
  background: rgba(139, 0, 0, 0.4);
  color: var(--accent-gold-bright);
  font-family: var(--font-serif);
  font-size: 15px;
}

.stem-char, .branch-char {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: bold;
}

.wuxing-meter {
  display: flex;
  gap: 12px;
  margin: 20px 0;
}

.wuxing-item {
  flex: 1;
  background: rgba(15, 12, 22, 0.6);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
  border: 1px solid var(--border-gold);
}

.wuxing-bar-bg {
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 6px;
}

.wuxing-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

/* ==========================================================================
   Modals & Popups
   ========================================================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--accent-gold);
  border-radius: var(--radius-lg);
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.8);
  position: relative;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
}

.modal-close:hover { color: #FFF; }

/* Responsive adjustments & Mobile Bottom Navigation Bar */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  body {
    padding-bottom: 70px; /* Leave space for bottom nav bar */
  }

  .header-container { flex-direction: column; align-items: flex-start; gap: 6px; }
  .title-text { font-size: 18px; }
  .nav-scroll { display: none; } /* Hide top tab scroll bar on mobile, use bottom nav instead */
  .almanac-banner { padding: 16px; }
  .solar-lunar-title { font-size: 18px; }

  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(15, 12, 22, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-gold);
    z-index: 999;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
  }

  .mobile-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 11px;
    padding: 6px;
    cursor: pointer;
    flex: 1;
    transition: all 0.2s ease;
  }

  .mobile-nav-btn .icon {
    font-size: 20px;
    margin-bottom: 2px;
    transition: transform 0.2s ease;
  }

  .mobile-nav-btn.active {
    color: var(--accent-gold-bright);
  }

  .mobile-nav-btn.active .icon {
    transform: translateY(-2px) scale(1.1);
  }

  .portal-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .main-content {
    padding: 12px;
  }
}
