/* ================================================================
   RAVIA.VN — Kinh Dịch AI
   style.css — Main Stylesheet
   ================================================================ */

/* ===== CSS VARIABLES ===== */
:root {
  --bg-dark: #0D0808;
  --bg-card: #1A1010;
  --bg-card2: #150F0F;
  --gold: #D4AF37;
  --gold-light: #F0D060;
  --gold-dark: #A08020;
  --red: #8B1A1A;
  --red-light: #C0392B;
  --text: #F5E6C8;
  --text-muted: #A09070;
  --border: rgba(212, 175, 55, 0.2);
  --border-hover: rgba(212, 175, 55, 0.6);
  --shadow: 0 4px 30px rgba(212, 175, 55, 0.1);
  --radius: 12px;
  --transition: all 0.3s ease;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
  /* Firefox scrollbar */
  scrollbar-width: thin;
  scrollbar-color: #D4AF37 #1a0808;
}

body {
  background: var(--bg-dark);
  color: var(--text);
  font-family: 'Be Vietnam Pro', sans-serif;
  line-height: 1.7;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== CUSTOM SCROLLBAR (WebKit) ===== */
::-webkit-scrollbar            { width: 5px; }
::-webkit-scrollbar-track      { background: #120808; }
::-webkit-scrollbar-thumb      {
  background: linear-gradient(180deg, #D4AF37 0%, #8a6a10 50%, #D4AF37 100%);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: #F0D060; }

/* page-leaving fallback (loader handles main transition) */
body.page-leaving { pointer-events: none; }

img { max-width: 100%; display: block; }
a { color: inherit; }
button { font-family: 'Be Vietnam Pro', sans-serif; }

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4 {
  font-family: 'Playfair Display', serif;
  line-height: 1.3;
}

h1 { font-size: clamp(2rem, 5vw, 4rem); line-height: 1.2; }
h2 { font-size: clamp(1.5rem, 3vw, 2.5rem); margin-bottom: 1rem; }
h3 { font-size: clamp(1rem, 2vw, 1.3rem); }

.text-gold {
  background: linear-gradient(135deg, var(--gold), var(--gold-light), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ===== LAYOUT ===== */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

.section {
  padding: 80px 0;
}

/* ===== UTILITY ===== */
.text-center { text-align: center; }
.d-none { display: none; }

/* ===== SECTION HEADER ===== */
.section-header {
  text-align: center;
  margin-bottom: 60px;
}

.section-tag {
  font-size: 0.75rem;
  letter-spacing: 3px;
  color: var(--gold);
  text-transform: uppercase;
  display: block;
  margin-bottom: 12px;
}

.section-label {
  text-align: center;
  font-size: 0.8rem;
  letter-spacing: 3px;
  color: var(--gold);
  margin-bottom: 15px;
}

.subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 50px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.8;
}

/* ================================================================
   HERO SECTION
   ================================================================ */

#hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  position: relative;
  overflow: hidden;
  padding-top: 80px;
}

#hero-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at center,
    rgba(139, 26, 26, 0.15) 0%,
    rgba(13, 8, 8, 0.8) 70%
  );
  z-index: 1;
}

.hero-content {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 60px 20px;
  width: 100%;
}

.hero-badge {
  display: inline-block;
  border: 1px solid var(--border-hover);
  padding: 6px 20px;
  border-radius: 50px;
  font-size: 0.8rem;
  letter-spacing: 2px;
  color: var(--gold);
  margin-bottom: 30px;
  background: rgba(212, 175, 55, 0.05);
  font-family: 'Be Vietnam Pro', sans-serif;
}

.hero-title {
  margin-bottom: 24px;
}

.hero-title .line1 {
  color: var(--text);
  display: block;
}

.hero-title .line2 {
  display: block;
}

.hero-subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 580px;
  margin: 0 auto 44px;
  line-height: 1.8;
}

.hero-buttons {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 70px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--red), #A52020);
  color: white;
  padding: 16px 36px;
  border-radius: 50px;
  border: none;
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  display: inline-block;
}

.btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(139, 26, 26, 0.5);
  background: linear-gradient(135deg, #A52020, var(--red));
}

.btn-outline {
  background: transparent;
  color: var(--gold);
  padding: 16px 36px;
  border-radius: 50px;
  border: 1px solid var(--border-hover);
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  display: inline-block;
  font-family: 'Be Vietnam Pro', sans-serif;
}

.btn-outline:hover {
  background: rgba(212, 175, 55, 0.1);
  transform: translateY(-2px);
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 50px;
  flex-wrap: wrap;
}

.stat-item {
  text-align: center;
}

.stat-num {
  font-family: 'Playfair Display', serif;
  font-size: 1.6rem;
  color: var(--gold);
  display: block;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.stat-divider {
  width: 1px;
  height: 40px;
  background: var(--border);
  align-self: center;
}

/* Floating hexagrams */
.floating-hex {
  position: absolute;
  font-size: 3rem;
  opacity: 0.05;
  animation: floatHex 8s infinite ease-in-out;
  color: var(--gold);
  pointer-events: none;
  z-index: 1;
  user-select: none;
}

.floating-hex:nth-child(1) { top: 10%; left: 5%; animation-delay: 0s; font-size: 4rem; }
.floating-hex:nth-child(2) { top: 20%; right: 8%; animation-delay: 2s; font-size: 3rem; }
.floating-hex:nth-child(3) { bottom: 20%; left: 10%; animation-delay: 4s; font-size: 5rem; }
.floating-hex:nth-child(4) { bottom: 10%; right: 5%; animation-delay: 1s; font-size: 2.5rem; }
.floating-hex:nth-child(5) { top: 50%; left: 2%; animation-delay: 3s; font-size: 2rem; }

@keyframes floatHex {
  0%, 100% { transform: translateY(0) rotate(0deg); opacity: 0.05; }
  50% { transform: translateY(-20px) rotate(5deg); opacity: 0.12; }
}

/* ================================================================
   HOW IT WORKS
   ================================================================ */

#how-it-works {
  background: linear-gradient(180deg, var(--bg-dark), var(--bg-card));
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 30px;
  position: relative;
}

.steps-grid::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 15%;
  right: 15%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-hover), transparent);
  display: none;
}

.step-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 30px;
  text-align: center;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.step-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.step-card:hover {
  transform: translateY(-5px);
  border-color: var(--border-hover);
  box-shadow: var(--shadow);
}

.step-num {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--red), #A52020);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-weight: 700;
  margin: 0 auto 16px;
  color: white;
}

.step-icon {
  font-size: 2.5rem;
  margin-bottom: 14px;
  display: block;
}

.step-card h3 {
  font-size: 1.1rem;
  color: var(--gold);
  margin-bottom: 10px;
  letter-spacing: 1px;
}

.step-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.7;
}

/* ================================================================
   DIVINATION FORM
   ================================================================ */

#gieo-que {
  background: var(--bg-card);
  position: relative;
}

#gieo-que::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23D4AF37' fill-opacity='0.02'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}

.section-divination {
  padding: 80px 0;
}

.form-container {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 44px;
  max-width: 760px;
  margin: 0 auto;
  position: relative;
}

.form-group {
  margin-bottom: 28px;
}

.form-group label {
  display: block;
  font-family: 'Playfair Display', serif;
  font-size: 0.88rem;
  color: var(--gold);
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.time-inputs,
.date-inputs {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.input-wrap {
  position: relative;
  flex: 1;
  min-width: 90px;
}

.inp {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  color: var(--text);
  font-size: 1rem;
  font-family: 'Be Vietnam Pro', sans-serif;
  transition: var(--transition);
  appearance: none;
  -webkit-appearance: none;
}

.inp:focus {
  outline: none;
  border-color: var(--gold);
  background: rgba(212, 175, 55, 0.05);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
}

.inp::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

/* Remove number input arrows */
.inp[type="number"]::-webkit-inner-spin-button,
.inp[type="number"]::-webkit-outer-spin-button {
  opacity: 0.3;
}

.inp-label {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.72rem;
  color: var(--text-muted);
  pointer-events: none;
}

.separator {
  font-size: 1.5rem;
  color: var(--text-muted);
  padding: 0 4px;
  user-select: none;
}

.btn-auto-time {
  background: none;
  border: 1px solid var(--border);
  color: var(--gold);
  padding: 8px 18px;
  border-radius: 50px;
  font-size: 0.8rem;
  cursor: pointer;
  margin-top: 10px;
  transition: var(--transition);
  display: inline-block;
}

.btn-auto-time:hover {
  background: rgba(212, 175, 55, 0.1);
  border-color: var(--border-hover);
}

.hint {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 8px;
  display: block;
  line-height: 1.6;
}

.link-gold {
  color: var(--gold);
  text-decoration: none;
  border-bottom: 1px dotted var(--gold);
}

.link-gold:hover {
  opacity: 0.8;
}

.inp-textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.7;
}

.topic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  align-items: center;
}

.chip-label {
  font-size: 0.73rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.chip {
  background: rgba(212, 175, 55, 0.07);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 50px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Be Vietnam Pro', sans-serif;
}

.chip:hover,
.chip.active {
  background: rgba(212, 175, 55, 0.2);
  border-color: var(--gold);
  color: var(--gold);
}

.btn-submit {
  width: 100%;
  background: linear-gradient(135deg, var(--red), #B02020, var(--red));
  background-size: 200% auto;
  color: white;
  border: none;
  padding: 20px;
  border-radius: 12px;
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  letter-spacing: 3px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  margin-top: 10px;
}

.btn-submit::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transition: 0.5s;
}

.btn-submit:hover::before {
  left: 100%;
}

.btn-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(139, 26, 26, 0.5);
  background-position: right center;
}

.btn-submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.btn-loading {
  display: none;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

/* ================================================================
   RESULTS AREA
   ================================================================ */

#result-area {
  margin-top: 50px;
  animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.hexagram-display {
  background: var(--bg-card2);
  border: 1px solid var(--border-hover);
  border-radius: 16px;
  padding: 40px;
  margin-bottom: 30px;
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 30px;
  align-items: start;
}

.hex-main {
  text-align: center;
  padding: 20px;
  border-right: 1px solid var(--border);
}

.hex-symbol {
  font-size: 5rem;
  animation: hexReveal 0.5s ease;
  display: block;
  margin-bottom: 12px;
  line-height: 1;
}

@keyframes hexReveal {
  from { transform: scale(0) rotate(180deg); opacity: 0; }
  to { transform: scale(1) rotate(0deg); opacity: 1; }
}

.hex-name {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  color: var(--gold);
  margin-bottom: 6px;
}

.hex-number {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.calc-breakdown h4 {
  font-size: 0.78rem;
  letter-spacing: 2px;
  color: var(--gold);
  margin-bottom: 14px;
  text-transform: uppercase;
}

.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.calc-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.calc-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.calc-value {
  font-family: 'Playfair Display', serif;
  font-size: 0.9rem;
  color: var(--text);
}

.the-dung-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(212, 175, 55, 0.05);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
}

.td-item {
  flex: 1;
  text-align: center;
}

.td-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.td-value {
  font-family: 'Playfair Display', serif;
  font-size: 0.95rem;
  color: var(--text);
}

.td-arrow {
  font-size: 0.85rem;
  color: var(--gold);
  min-width: 90px;
  text-align: center;
  line-height: 1.5;
}

.derived-ques {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.dq-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}

.dq-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.dq-value {
  font-family: 'Playfair Display', serif;
  font-size: 0.85rem;
  color: var(--text);
}

.luan-que-box {
  background: var(--bg-card2);
  border: 1px solid var(--border-hover);
  border-radius: 16px;
  padding: 44px;
}

.luan-header {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 28px;
  justify-content: center;
}

.luan-header h3 {
  font-size: 1.3rem;
  color: var(--gold);
  letter-spacing: 3px;
}

.luan-icon {
  color: var(--gold);
  font-size: 0.9rem;
}

/* ── Loading animation for Luận Quẻ ── */
.luan-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2.5rem 1rem;
  gap: 1.2rem;
}
.luan-loading-spinner {
  font-size: 3.5rem;
  animation: spinYin 3s linear infinite;
  filter: drop-shadow(0 0 12px rgba(212,175,55,0.6));
}
@keyframes spinYin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.luan-loading-bar {
  width: 220px;
  height: 5px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
}
.luan-loading-bar-fill {
  height: 100%;
  width: 60%;
  background: linear-gradient(90deg, transparent, #d4af37, #f5d36a, #d4af37, transparent);
  background-size: 200% 100%;
  animation: luanShimmer 1.6s ease-in-out infinite;
}
@keyframes luanShimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}
.luan-loading-text {
  color: var(--gold);
  font-size: 0.9rem;
  letter-spacing: 1px;
  animation: luanPulse 2s ease-in-out infinite;
}
@keyframes luanPulse {
  0%, 100% { opacity: 0.5; }
  50%       { opacity: 1; }
}

.luan-content {
  color: var(--text);
  line-height: 1.9;
  font-size: 0.95rem;
}

.luan-content h4 {
  color: var(--gold);
  margin: 20px 0 8px;
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
}

.luan-content ul {
  margin: 10px 0 10px 20px;
}

.luan-content li {
  margin-bottom: 5px;
}

.luan-content p {
  margin-bottom: 12px;
}

.luan-content strong {
  color: var(--gold);
}

.citation-box {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.citation-box small {
  color: var(--text-muted);
  font-size: 0.73rem;
  line-height: 1.6;
}

.result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 28px;
  flex-wrap: wrap;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 12px 24px;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.85rem;
  font-family: 'Be Vietnam Pro', sans-serif;
}

.btn-secondary:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(212, 175, 55, 0.05);
}

/* ================================================================
   TOPICS SECTION
   ================================================================ */

#linh-vuc {
  background: var(--bg-dark);
}

.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.topic-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  color: inherit;
  display: block;
  position: relative;
  overflow: hidden;
}

.topic-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  transform: scaleX(0);
  transition: var(--transition);
}

.topic-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.topic-card:hover::after {
  transform: scaleX(1);
}

.topic-icon {
  font-size: 2.4rem;
  margin-bottom: 14px;
  display: block;
}

.topic-card h3 {
  color: var(--gold);
  margin-bottom: 8px;
  font-size: 1rem;
  letter-spacing: 1px;
}

.topic-card p {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.6;
}

.topic-card .example {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  opacity: 0.75;
}

/* ================================================================
   KNOWLEDGE SECTION
   ================================================================ */

#kien-thuc {
  background: linear-gradient(180deg, var(--bg-card), var(--bg-dark));
}

.knowledge-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 50px;
  align-items: start;
}

.knowledge-text p {
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.85;
  font-size: 0.95rem;
}

.quote-block {
  border-left: 3px solid var(--gold);
  padding: 20px 25px;
  background: rgba(212, 175, 55, 0.05);
  border-radius: 0 8px 8px 0;
  margin: 28px 0;
}

.quote-block p {
  color: var(--text) !important;
  font-style: italic;
  font-size: 0.95rem !important;
  margin: 0 0 8px !important;
}

.quote-block cite {
  font-size: 0.73rem;
  color: var(--gold);
  display: block;
  font-style: normal;
  letter-spacing: 1px;
}

.disclaimer-box {
  background: rgba(139, 26, 26, 0.1);
  border: 1px solid rgba(139, 26, 26, 0.3);
  border-radius: 8px;
  padding: 16px 20px;
  margin-top: 20px;
}

.disclaimer-box p {
  color: var(--text-muted) !important;
  font-size: 0.82rem !important;
  margin: 0 !important;
}

.books-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.book-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  display: flex;
  gap: 15px;
  align-items: flex-start;
  transition: var(--transition);
}

.book-item:hover {
  border-color: var(--border-hover);
}

.book-icon {
  font-size: 2rem;
  flex-shrink: 0;
  line-height: 1;
}

.book-info { flex: 1; }

.book-title {
  font-family: 'Playfair Display', serif;
  font-size: 0.88rem;
  color: var(--gold);
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

.book-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ================================================================
   FAQ SECTION
   ================================================================ */

#faq {
  background: var(--bg-card);
}

.faq-list {
  max-width: 760px;
  margin: 0 auto;
}

.faq-item {
  border-bottom: 1px solid var(--border);
}

.faq-item:first-child {
  border-top: 1px solid var(--border);
}

.faq-q {
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 22px 0;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  transition: var(--transition);
  font-family: 'Be Vietnam Pro', sans-serif;
  line-height: 1.5;
}

.faq-q:hover {
  color: var(--gold);
}

.faq-q .faq-icon {
  color: var(--gold);
  font-size: 1.2rem;
  transition: transform 0.3s ease;
  flex-shrink: 0;
  font-style: normal;
}

.faq-q.active {
  color: var(--gold);
}

.faq-q.active .faq-icon {
  transform: rotate(45deg);
}

.faq-a {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
}

.faq-a p {
  padding: 0 0 22px;
  color: var(--text-muted);
  line-height: 1.85;
  font-size: 0.9rem;
  max-width: 680px;
}

/* ================================================================
   FOOTER
   ================================================================ */

footer {
  background: #080505;
  border-top: 1px solid var(--border);
  padding: 70px 0 35px;
}

.footer-top {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 50px;
  margin-bottom: 50px;
}

.footer-brand .logo {
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  text-decoration: none;
}

.footer-brand p {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.85;
  max-width: 300px;
}

.footer-slogan {
  color: var(--gold);
  font-style: italic;
  font-size: 0.88rem;
  margin-top: 12px;
  display: block;
  opacity: 0.8;
}

.footer-col h4 {
  font-family: 'Playfair Display', serif;
  font-size: 0.82rem;
  color: var(--gold);
  letter-spacing: 2px;
  margin-bottom: 20px;
  text-transform: uppercase;
}

.footer-col ul {
  list-style: none;
}

.footer-col ul li {
  margin-bottom: 12px;
}

.footer-col ul li a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  transition: var(--transition);
  display: inline-block;
}

.footer-col ul li a:hover {
  color: var(--gold);
  transform: translateX(3px);
}

.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 28px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.footer-bottom a {
  color: var(--gold);
  text-decoration: none;
  opacity: 0.7;
}

.footer-bottom a:hover {
  opacity: 1;
}

.footer-seo {
  margin-top: 22px;
  font-size: 0.73rem;
  color: #3a2a1a;
  line-height: 1.7;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

/* ================================================================
   LOADING SPINNER
   ================================================================ */

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(212, 175, 55, 0.3);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ================================================================
   MODAL
   ================================================================ */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-hover);
  border-radius: 16px;
  padding: 44px;
  max-width: 520px;
  width: 100%;
  position: relative;
  animation: fadeInUp 0.3s ease;
}

.modal h3 {
  color: var(--gold);
  margin-bottom: 16px;
  font-size: 1.1rem;
  letter-spacing: 1px;
}

.modal p {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.85;
  margin-bottom: 12px;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  transition: var(--transition);
  line-height: 1;
  padding: 4px;
}

.modal-close:hover {
  color: var(--gold);
}

.modal .btn-primary {
  margin-top: 10px;
  width: 100%;
  text-align: center;
  font-size: 0.9rem;
  padding: 14px;
}

/* ================================================================
   TOAST NOTIFICATION
   ================================================================ */

.toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: var(--bg-card);
  border: 1px solid var(--border-hover);
  border-radius: 10px;
  padding: 14px 24px;
  color: var(--text);
  font-size: 0.85rem;
  z-index: 3000;
  animation: slideInRight 0.3s ease;
  max-width: 320px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

@keyframes slideInRight {
  from { transform: translateX(110%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ================================================================
   SCROLL ANIMATIONS
   ================================================================ */

.fade-up {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.65s ease, transform 0.65s ease;
}

.fade-up.visible {
  opacity: 1;
  transform: translateY(0);
}

.fade-up:nth-child(2) { transition-delay: 0.1s; }
.fade-up:nth-child(3) { transition-delay: 0.2s; }

/* ================================================================
   RESULT COLOR CLASSES
   ================================================================ */

.result-tot { color: #27AE60; }
.result-trung { color: #F39C12; }
.result-xau { color: #E74C3C; }
.result-xau-nhat { color: #C0392B; font-weight: 700; }

.vuong { color: #27AE60; }
.tuong { color: #2ECC71; }
.huu { color: #F39C12; }
.tu { color: #E67E22; }
.tu-dead { color: #E74C3C; }

/* ================================================================
   RESPONSIVE — TABLET
   ================================================================ */

@media (max-width: 900px) {
  .knowledge-grid {
    grid-template-columns: 1fr;
    gap: 30px;
  }

  .hexagram-display {
    grid-template-columns: 1fr;
  }

  .hex-main {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-bottom: 24px;
    margin-bottom: 24px;
  }

  .footer-top {
    grid-template-columns: 1fr 1fr;
  }

  .footer-brand {
    grid-column: 1 / -1;
  }
}

/* ================================================================
   RESPONSIVE — MOBILE
   ================================================================ */

@media (max-width: 768px) {
  .section { padding: 60px 0; }
  .section-divination { padding: 60px 0; }

  /* Navbar mobile */
  .nav-menu {
    display: none;
  }

  .nav-toggle {
    display: block;
  }

  .nav-menu.open {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 65px;
    left: 0;
    right: 0;
    background: rgba(13, 8, 8, 0.98);
    padding: 30px 20px;
    gap: 20px;
    border-bottom: 1px solid var(--border);
    align-items: flex-start;
    backdrop-filter: blur(10px);
  }

  .nav-menu.open .nav-cta {
    align-self: center;
  }

  /* Hero mobile */
  .hero-buttons {
    flex-direction: column;
    align-items: center;
  }

  .btn-primary, .btn-outline {
    width: 100%;
    max-width: 300px;
    text-align: center;
  }

  .hero-stats {
    gap: 20px;
  }

  .stat-divider {
    display: none;
  }

  /* Form mobile */
  .form-container {
    padding: 24px 18px;
  }

  .date-inputs {
    flex-wrap: wrap;
  }

  .date-inputs .inp {
    min-width: 80px;
  }

  /* Topics grid */
  .topics-grid {
    grid-template-columns: 1fr;
  }

  /* Results */
  .hexagram-display {
    padding: 24px;
  }

  .luan-que-box {
    padding: 24px;
  }

  /* Footer */
  .footer-top {
    grid-template-columns: 1fr;
    gap: 30px;
  }

  .footer-brand {
    grid-column: auto;
  }

  /* Steps */
  .steps-grid {
    grid-template-columns: 1fr;
  }

  /* Toast */
  .toast {
    bottom: 16px;
    right: 16px;
    left: 16px;
    max-width: none;
  }

  /* Calc grid */
  .calc-grid {
    grid-template-columns: 1fr;
  }

  .derived-ques {
    grid-template-columns: 1fr;
  }

  .the-dung-box {
    flex-direction: column;
    text-align: center;
  }

  .td-arrow {
    min-width: auto;
  }
}

@media (max-width: 400px) {
  h1 { font-size: 1.8rem; }
  .hero-badge { font-size: 0.7rem; letter-spacing: 1px; padding: 5px 14px; }
  .form-container { padding: 18px 14px; }
}

/* ================================================================
   METHOD SELECTOR
   ================================================================ */
.method-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.method-tab {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 10px 18px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 0.88rem;
  transition: var(--transition);
  font-weight: 500;
}
.method-tab.active {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(212,175,55,0.08);
}
.method-tab:hover:not(.active) {
  border-color: var(--border-hover);
  color: var(--text);
}
.method-desc {
  background: rgba(212,175,55,0.04);
  border: 1px solid rgba(212,175,55,0.15);
  border-left: 3px solid var(--gold-dark);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 24px;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
}
.method-score {
  display: inline-block;
  background: var(--gold-dark);
  color: #000;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  margin-left: 6px;
  vertical-align: middle;
}

/* ================================================================
   LỤC HÀO INPUT
   ================================================================ */
.hao-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}
.hao-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.hao-row-label {
  min-width: 72px;
  font-size: 0.82rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.hao-options {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.hao-btn {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 11px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: var(--transition);
  white-space: nowrap;
  font-family: 'Be Vietnam Pro', sans-serif;
}
.hao-btn:hover {
  border-color: var(--border-hover);
}
.hao-btn.selected {
  background: rgba(212,175,55,0.1);
  border-color: var(--gold);
  color: var(--gold);
  font-weight: 600;
}
.hao-result-preview {
  display: flex;
  gap: 4px;
  margin-top: 14px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}
.hao-line {
  font-size: 1.4rem;
  color: var(--text-muted);
  line-height: 1;
  width: 32px;
  text-align: center;
  transition: color 0.2s;
}
.hao-line.yang { color: var(--gold); }
.hao-line.yin  { color: var(--text-muted); }
.hao-line.moving { color: var(--gold-light); }
.hao-divider-line {
  width: 1px;
  height: 36px;
  background: var(--border);
  margin: 0 8px;
}

/* ================================================================
   REALTIME CLOCK
   ================================================================ */
.realtime-clock-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 14px;
  background: rgba(212,175,55,0.05);
  border: 1px solid rgba(212,175,55,0.15);
  border-radius: 8px;
  width: fit-content;
}
.clock-icon { font-size: 0.9rem; }
.clock-text {
  font-size: 0.92rem;
  color: var(--gold);
  font-family: 'Be Vietnam Pro', monospace;
  letter-spacing: 0.5px;
}

/* ================================================================
   SUBMIT GROUP (Gieo / Gieo & Luan)
   ================================================================ */
.submit-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.btn-gieo {
  flex: 1;
  min-width: 140px;
  background: linear-gradient(135deg, #1A1010, #2A1A0A);
  border: 2px solid var(--gold-dark);
}
.btn-gieo:hover {
  border-color: var(--gold);
  background: rgba(212,175,55,0.1);
}
.btn-both {
  flex: 1.5;
  min-width: 180px;
}
.submit-hint {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 10px;
}

/* ================================================================
   LUAN ACTIONS
   ================================================================ */
.luan-actions {
  margin: 20px 0 10px;
  display: flex;
  justify-content: center;
}
.btn-luan {
  background: linear-gradient(135deg, rgba(212,175,55,0.15), rgba(212,175,55,0.05));
  border: 1px solid var(--gold);
  color: var(--gold);
  padding: 16px 32px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  transition: var(--transition);
  text-align: center;
  min-width: 280px;
}
.btn-luan:hover {
  background: linear-gradient(135deg, rgba(212,175,55,0.25), rgba(212,175,55,0.1));
  box-shadow: 0 0 20px rgba(212,175,55,0.2);
}
.btn-luan:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.btn-luan-text { display: block; }

/* ================================================================
   6-TAB METHOD LAYOUT
   ================================================================ */
.method-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 24px;
}
@media (max-width: 600px) {
  .method-tabs { grid-template-columns: repeat(2, 1fr); }
}
.method-tab {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 10px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 0.82rem;
  transition: var(--transition);
  font-weight: 500;
  text-align: center;
  line-height: 1.4;
}
.method-tab .tab-icon { display: block; font-size: 1.3rem; margin-bottom: 4px; }
.method-tab .tab-score {
  display: inline-block;
  background: rgba(212,175,55,0.15);
  color: var(--gold-dark);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  margin-left: 4px;
}
.method-tab.active {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(212,175,55,0.08);
}
.method-tab:hover:not(.active) {
  border-color: var(--border-hover);
  color: var(--text);
}

/* ================================================================
   COIN GRAPHICS (3D flip style)
   ================================================================ */
.coin-rows { display: flex; flex-direction: column; gap: 16px; }

.coin-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.coin-row-label {
  min-width: 70px;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.coin-set {
  display: flex;
  gap: 8px;
  align-items: center;
}
/* Individual coin */
.coin-item {
  width: 44px; height: 44px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all 0.25s cubic-bezier(.4,2,.6,1);
  user-select: none;
  position: relative;
  background: var(--bg-card2);
  color: var(--text-muted);
}
.coin-item:hover { border-color: var(--gold-dark); transform: scale(1.1); }
.coin-item.nguya {
  background: radial-gradient(circle at 35% 35%, #f5d060, #d4af37, #a08020);
  border-color: var(--gold);
  color: #3a2800;
  box-shadow: 0 2px 8px rgba(212,175,55,0.4), inset 0 1px 0 rgba(255,255,255,0.3);
}
.coin-item.sap {
  background: radial-gradient(circle at 35% 35%, #4a4a4a, #2a2a2a, #1a1a1a);
  border-color: #555;
  color: #888;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05);
}
.coin-item.flip-anim {
  animation: coinFlip 0.35s ease;
}
@keyframes coinFlip {
  0% { transform: scaleX(1); }
  50% { transform: scaleX(0.05); }
  100% { transform: scaleX(1); }
}
/* Coin row result indicator */
.coin-row-result {
  margin-left: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
  min-width: 90px;
}
.coin-row-result.yang { color: var(--gold); }
.coin-row-result.yin  { color: #9090a0; }
.coin-row-result.moving { color: var(--gold-light); font-weight: 600; }

/* Toss all button style */
.btn-toss-all {
  background: rgba(212,175,55,0.1);
  border: 1px solid var(--gold-dark);
  color: var(--gold);
  padding: 10px 20px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  transition: var(--transition);
  margin-bottom: 16px;
}
.btn-toss-all:hover { background: rgba(212,175,55,0.2); }

/* ================================================================
   HEXAGRAM GRAPHIC LINES
   ================================================================ */
.hexagram-graphic {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  align-items: flex-start;
}
.hao-graphic-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.hao-line-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  width: 36px;
  text-align: right;
  flex-shrink: 0;
}
.hao-line-graphic {
  display: flex;
  gap: 4px;
  align-items: center;
}
/* Yang line: single solid bar */
.hao-yang {
  width: 80px; height: 8px;
  background: var(--gold);
  border-radius: 4px;
  box-shadow: 0 0 6px rgba(212,175,55,0.3);
}
/* Yin line: two broken bars */
.hao-yin {
  display: flex;
  gap: 6px;
}
.hao-yin-half {
  width: 35px; height: 8px;
  background: var(--text-muted);
  border-radius: 4px;
  opacity: 0.6;
}
/* Moving marker */
.hao-moving-mark {
  font-size: 0.85rem;
  margin-left: 6px;
}
.hao-moving-mark.yang-moving { color: var(--gold-light); }
.hao-moving-mark.yin-moving  { color: #9090a0; }
/* Trigram divider */
.hexagram-divider {
  width: 88px;
  height: 1px;
  background: var(--border);
  margin: 2px 0 2px 46px;
}

/* ================================================================
   YARROW STALK (Co Thi) UI — graphical tube + shake animation
   ================================================================ */
.cathi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
}
@media (max-width: 480px) { .cathi-grid { grid-template-columns: repeat(2, 1fr); } }

.cathi-hao-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 14px 8px 12px;
  background: var(--bg-card2);
  border-radius: 12px;
  border: 1px solid var(--border);
  transition: border-color 0.4s;
}
.cathi-hao-wrap.done { border-color: var(--gold); }
.cathi-hao-label {
  font-size: 0.76rem;
  color: var(--text-muted);
  text-align: center;
  font-family: 'Be Vietnam Pro', sans-serif;
}
.cathi-vessel { display: flex; flex-direction: column; align-items: center; }

/* Stalks sticking up from the tube */
.cathi-stalks-up {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  width: 76px;
  overflow: hidden;
  padding: 0 3px;
}
.cathi-st {
  flex: 0 0 auto;
  width: 4px;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(to top, #5c3d11, #c9a227, #f0e080);
  transform-origin: bottom center;
  transition: height 0.5s cubic-bezier(0.34,1.56,0.64,1), background 0.4s;
}
.cathi-st.hi {
  background: linear-gradient(to top, #8B2200, #e06020, #FFD700);
}

/* Tube / vessel body */
.cathi-tube {
  width: 76px;
  height: 68px;
  background: linear-gradient(160deg, #6b4c11 0%, #8B6914 30%, #a07820 55%, #6b4c11 80%, #3d2508 100%);
  border-radius: 6px 6px 14px 14px;
  border: 2px solid #c9941a;
  box-shadow: inset 2px 0 8px rgba(255,210,60,0.12), inset -3px 0 10px rgba(0,0,0,0.55), 0 5px 14px rgba(0,0,0,0.45);
  position: relative;
  transform-origin: bottom center;
}
.cathi-tube-rim {
  position: absolute;
  top: -7px; left: -2px; right: -2px;
  height: 11px;
  background: linear-gradient(to bottom, #f0c030, #a07820, #c9941a);
  border-radius: 5px 5px 2px 2px;
  border: 1px solid #f5d060;
  box-shadow: 0 -2px 8px rgba(240,192,48,0.35);
}

/* Shake animation */
@keyframes xocShake {
  0%   { transform: rotate(0deg) translateX(0); }
  7%   { transform: rotate(-20deg) translateX(-5px); }
  15%  { transform: rotate(18deg) translateX(5px); }
  23%  { transform: rotate(-16deg) translateX(-4px); }
  31%  { transform: rotate(13deg) translateX(4px); }
  39%  { transform: rotate(-10deg) translateX(-2px); }
  47%  { transform: rotate(8deg) translateX(2px); }
  55%  { transform: rotate(-6deg) translateX(-1px); }
  63%  { transform: rotate(4deg) translateX(1px); }
  71%  { transform: rotate(-3deg); }
  79%  { transform: rotate(2deg); }
  87%  { transform: rotate(-1deg); }
  94%  { transform: rotate(0.5deg); }
  100% { transform: rotate(0deg) translateX(0); }
}
.cathi-tube.xoc-active {
  animation: xocShake 1.3s cubic-bezier(0.36, 0.07, 0.19, 0.97) forwards;
}

/* Stalk sway */
@keyframes stalkSway {
  0%,100% { transform: rotate(0deg); }
  10%  { transform: rotate(-14deg); }
  22%  { transform: rotate(11deg); }
  35%  { transform: rotate(-8deg); }
  48%  { transform: rotate(6deg); }
  61%  { transform: rotate(-4deg); }
  74%  { transform: rotate(2deg); }
  87%  { transform: rotate(-1deg); }
}
.cathi-st.sway-active {
  animation: stalkSway 1.3s ease-out forwards;
}

.cathi-result-badge {
  font-size: 0.78rem;
  min-height: 18px;
  text-align: center;
  font-weight: 600;
}
.btn-xoc {
  background: linear-gradient(135deg, rgba(139,105,20,0.2), rgba(212,175,55,0.12));
  border: 1px solid #8b6914;
  color: #d4af37;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  transition: var(--transition);
  font-family: 'Be Vietnam Pro', sans-serif;
}
.btn-xoc:hover { background: rgba(139,105,20,0.36); border-color: #d4af37; }
.btn-xoc:disabled { opacity: 0.45; cursor: not-allowed; }

/* ================================================================
   TUONG METHOD (Quan sat hien tuong)
   ================================================================ */
.tuong-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}
.tuong-example-chip {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: var(--transition);
}
.tuong-example-chip:hover {
  border-color: var(--gold-dark);
  color: var(--text);
}

/* ================================================================
   BACKGROUND CANVAS
   ================================================================ */
#bg-canvas {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  z-index: 0; pointer-events: none;
}

/* ================================================================
   WIZARD STEP TIMELINE
   ================================================================ */
.wizard-timeline {
  display: flex; align-items: center; justify-content: center;
  padding: 14px 16px 18px; gap: 0;
}
.wt-step { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.wt-dot {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; background: var(--bg-card2); color: var(--text-muted);
  font-family: 'Be Vietnam Pro', sans-serif; font-weight: 700;
  transition: all 0.4s ease;
  box-shadow: 0 0 0 0 rgba(212,175,55,0);
}
.wt-label {
  font-size: 0.62rem; color: var(--text-muted);
  white-space: nowrap; font-family: 'Be Vietnam Pro', sans-serif;
  transition: color 0.4s;
}
.wt-step.wt-active .wt-dot {
  border-color: var(--gold); color: var(--gold);
  box-shadow: 0 0 12px rgba(212,175,55,0.5);
}
.wt-step.wt-active .wt-label { color: var(--gold); font-weight: 600; }
.wt-step.wt-done .wt-dot {
  background: linear-gradient(135deg, #f0d040, #c9a020);
  border-color: var(--gold); color: #1a1000; font-size: 0.8rem;
}
.wt-step.wt-done .wt-label { color: var(--gold-light); }
.wt-line {
  flex: 1; height: 1.5px; background: var(--border);
  min-width: 20px; max-width: 52px; margin-bottom: 18px;
  transition: background 0.5s;
}
.wt-line.wt-filled { background: linear-gradient(to right, var(--gold), #a07820); }

/* ================================================================
   3D COIN — CSS preserve-3d (traditional Chinese cash coin)
   ================================================================ */
.coin3d-outer {
  perspective: 500px;
  width: 70px; height: 70px;
  cursor: pointer; display: inline-block; user-select: none;
}
.coin3d-outer:hover .coin3d-front { filter: brightness(1.12); }
.coin3d {
  width: 100%; height: 100%; position: relative;
  transform-style: preserve-3d;
}
.coin3d-face {
  position: absolute; width: 100%; height: 100%;
  border-radius: 50%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
/* Front — ngửa (yang, value 3): bright gold */
.coin3d-front {
  background:
    radial-gradient(circle at 37% 30%, #fff4a0 0%, #f5d858 12%, #d4af37 32%, #a07820 58%, #6b4c11 82%, #3a2406 100%);
  border: 2.5px solid #c9a020;
  box-shadow:
    0 6px 18px rgba(0,0,0,0.6),
    inset 3px 3px 7px rgba(255,235,80,0.3),
    inset -3px -3px 7px rgba(0,0,0,0.55);
}
.coin3d-front .coin-inner-ring {
  position: absolute; inset: 6px; border-radius: 50%;
  border: 1px solid rgba(70,45,8,0.35); pointer-events: none;
}
/* Square hole (fang kong 方孔) */
.coin3d-front .coin-hole {
  position: absolute; width: 21px; height: 21px;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: radial-gradient(#060402, #0d0805);
  border: 1.5px solid rgba(60,38,8,0.7);
  border-radius: 2px;
  box-shadow: inset 0 0 8px rgba(0,0,0,0.95), 0 0 4px rgba(0,0,0,0.6);
}
/* 4 trigram characters (Càn/Khôn/Ly/Khảm) */
.coin-char {
  position: absolute; font-size: 9.5px;
  font-family: 'Playfair Display', serif; font-weight: bold;
  color: rgba(30,16,2,0.92);
  text-shadow: 0 1px 0 rgba(255,210,50,0.45);
  pointer-events: none; line-height: 1;
}
.coin-ct { top: 7px; left: 50%; transform: translateX(-50%); }
.coin-cb { bottom: 7px; left: 50%; transform: translateX(-50%); }
.coin-cl { left: 7px; top: 50%; transform: translateY(-50%); }
.coin-cr { right: 7px; top: 50%; transform: translateY(-50%); }

/* Back — sấp (yin, value 2): dark copper */
.coin3d-back {
  background:
    radial-gradient(circle at 63% 70%, #c8a028 0%, #8B6914 28%, #5a3f08 58%, #2d1e04 85%, #180e02 100%);
  border: 2.5px solid #6b4c11;
  transform: rotateY(180deg);
  box-shadow:
    0 6px 18px rgba(0,0,0,0.7),
    inset 2px 2px 8px rgba(0,0,0,0.65),
    inset -2px -2px 6px rgba(0,0,0,0.75);
}
.coin3d-back .coin-hole {
  position: absolute; width: 21px; height: 21px;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: radial-gradient(#060402, #0d0805);
  border: 1.5px solid rgba(50,30,5,0.6);
  border-radius: 2px;
  box-shadow: inset 0 0 8px rgba(0,0,0,0.95);
}
.coin3d-back .coin-inner-ring {
  position: absolute; inset: 7px; border-radius: 50%;
  border: 1px dashed rgba(100,65,15,0.25); pointer-events: none;
}

/* Result glow */
.coin3d-outer[data-result="nguya"] .coin3d-front {
  box-shadow: 0 0 18px rgba(212,175,55,0.55), 0 6px 18px rgba(0,0,0,0.6), inset 3px 3px 7px rgba(255,235,80,0.3);
}
.coin3d-outer[data-result="sap"] .coin3d-back {
  box-shadow: 0 0 12px rgba(120,80,20,0.4), 0 6px 18px rgba(0,0,0,0.7);
}

/* Coin-set spacing */
.coin-set { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Tung xu button */
.btn-tung {
  background: rgba(212,175,55,0.1); border: 1px solid var(--gold-dark);
  color: var(--gold); padding: 7px 18px; border-radius: var(--radius);
  cursor: pointer; font-size: 0.85rem; font-weight: 600;
  transition: var(--transition); font-family: 'Be Vietnam Pro', sans-serif;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-tung:hover { background: rgba(212,175,55,0.22); transform: translateY(-1px); }

/* ================================================================
   THẺ XĂM 64 QUE — bamboo cylinder + stick pop animation
   ================================================================ */
.the-xam-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 24px; padding: 10px 0 16px;
}
.the-xam-scene {
  position: relative; display: flex; flex-direction: column; align-items: center;
}
/* The bamboo cylinder */
.txam-cup {
  width: 110px; height: 130px; position: relative;
  background: linear-gradient(160deg, #4a3309 0%, #6b4c11 25%, #9b7218 50%, #6b4c11 75%, #3a2407 100%);
  border-radius: 8px 8px 18px 18px;
  border: 3px solid #c9941a;
  box-shadow: inset -8px 0 18px rgba(0,0,0,0.55), inset 4px 0 8px rgba(255,200,50,0.08), 6px 10px 24px rgba(0,0,0,0.55);
  cursor: pointer; transform-origin: bottom center;
  /* Bamboo ring decorations */
  background-image:
    linear-gradient(to right, transparent 0%, rgba(0,0,0,0.15) 50%, transparent 100%),
    repeating-linear-gradient(to bottom, transparent 0px, transparent 28px, rgba(0,0,0,0.2) 28px, rgba(0,0,0,0.2) 30px);
}
.txam-cup-rim {
  position: absolute; top: -9px; left: -3px; right: -3px; height: 14px;
  background: linear-gradient(to bottom, #f5d050, #a87818, #c9941a);
  border-radius: 5px 5px 2px 2px;
  border: 1px solid #f0cc40;
  box-shadow: 0 -3px 10px rgba(245,210,80,0.4);
}
/* Sticks inside the cup, visible from top */
.txam-sticks-top {
  position: absolute; top: -70px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 2px; width: 96px; align-items: flex-end; overflow: hidden;
}
.txam-st {
  flex: 0 0 auto; width: 5px; border-radius: 3px 3px 0 0;
  background: linear-gradient(to top, #5c3d11, #c9a227, #f0e080);
  transform-origin: bottom center;
}
.txam-st.chosen {
  background: linear-gradient(to top, #8B2200, #e05520, #FFD700);
  width: 7px; z-index: 5;
}

/* Shake animation for the cup */
@keyframes txamShake {
  0%   { transform: rotate(0deg) translateX(0); }
  6%   { transform: rotate(-22deg) translateX(-6px); }
  13%  { transform: rotate(20deg) translateX(6px); }
  20%  { transform: rotate(-17deg) translateX(-5px); }
  27%  { transform: rotate(14deg) translateX(5px); }
  34%  { transform: rotate(-11deg) translateX(-3px); }
  41%  { transform: rotate(9deg) translateX(3px); }
  49%  { transform: rotate(-7deg) translateX(-2px); }
  57%  { transform: rotate(5deg) translateX(2px); }
  65%  { transform: rotate(-3deg); }
  73%  { transform: rotate(2deg); }
  82%  { transform: rotate(-1deg); }
  91%  { transform: rotate(0.5deg); }
  100% { transform: rotate(0deg) translateX(0); }
}
.txam-cup.shaking { animation: txamShake 1.5s cubic-bezier(0.36,0.07,0.19,0.97) forwards; }

/* Stick rising out animation */
@keyframes stickRise {
  0%  { transform: translateY(0) rotate(0deg); opacity: 1; }
  50% { transform: translateY(-55px) rotate(-5deg); opacity: 1; }
  75% { transform: translateY(-70px) rotate(10deg); opacity: 1; }
  90% { transform: translateY(-60px) rotate(25deg) translateX(20px); opacity: 0.9; }
  100%{ transform: translateY(-40px) rotate(40deg) translateX(40px); opacity: 0; }
}
.txam-st.chosen.rising { animation: stickRise 1.0s ease-out 1.3s forwards; }

/* Result display — fallen stick */
.txam-result-card {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  animation: fadeInUp 0.6s ease forwards;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.txam-fallen-stick {
  width: 220px; height: 44px;
  background: linear-gradient(90deg, #c9a227 0%, #f5e080 20%, #e8c840 50%, #f5e080 80%, #c9a227 100%);
  border-radius: 5px;
  border: 2px solid #8B6914;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.35);
  font-family: 'Playfair Display', serif; color: #2a1800;
  transform: rotate(-1.5deg);
  position: relative;
}
.txam-stick-num {
  font-size: 1.3rem; font-weight: bold; min-width: 32px; text-align: center;
  border-right: 1px solid rgba(80,50,10,0.3); padding-right: 10px;
}
.txam-stick-name { font-size: 0.92rem; font-weight: bold; }
.txam-que-info {
  text-align: center; padding: 14px 20px;
  background: var(--bg-card2); border-radius: 12px; border: 1px solid var(--gold-dark);
  max-width: 340px;
}
.txam-que-num { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 4px; }
.txam-que-name { font-family: 'Playfair Display', serif; font-size: 1.1rem; color: var(--gold); margin-bottom: 6px; }
.txam-que-hex { font-size: 2rem; margin-bottom: 6px; }
.txam-btn-wrap { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
