:root {
  --bg-color: #fcf9f2; /* Updated to match other pages */
  --text-color: #1a1a1a;
  --primary-color: #1a1a1a;
  --ink-color: #1a1a1a;
  --bubble-bg-system: #fff;
  --bubble-bg-user: #95ec69;
}

body {
  margin: 0;
  padding: 0;
  font-family: "Kaiti", "STKaiti", "Songti SC", serif; /* Ink style font */
  background: url('images/NorDi.png') no-repeat center center fixed;
  background-size: cover;
  color: var(--text-color);
  height: 100vh;
  overflow: hidden;
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
}

.step {
  display: none;
  width: 100%;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 0;
  left: 0;
  background: transparent;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.step.active {
  display: flex;
  opacity: 1;
  z-index: 10;
}

/* Step 1: Animation */
.ink-animation-container {
  font-size: 2rem;
  font-weight: bold;
  color: var(--ink-color);
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
}

.ink-text {
  opacity: 0;
  animation: ink-fade-in 2s forwards;
}

.ink-text:nth-child(1) { animation-delay: 0.5s; }
.ink-text:nth-child(2) { animation-delay: 2.5s; }
.ink-text:nth-child(3) { animation-delay: 4.5s; }

@keyframes ink-fade-in {
  0% { opacity: 0; transform: scale(0.8) blur(2px); }
  100% { opacity: 1; transform: scale(1) blur(0); }
}

/* Step 2: Intro */
.intro-card {
  text-align: center;
  padding: 20px;
}

.intro-img {
  max-width: 80%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  margin-bottom: 20px;
}

.intro-text {
  font-size: 1.2rem;
  color: #666;
  animation: fade-in 1s ease 1s forwards;
  opacity: 0;
}

@keyframes fade-in {
  to { opacity: 1; }
}

/* Chat Interface (Steps 3, 4, 5, 6) */
.chat-container {
  flex: 1;
  width: 100%;
  padding: var(--chat-container-padding, 12px);
  padding-bottom: 80px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
  justify-content: flex-start;
  padding-top: 60px;
}

.chat-message {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: var(--chat-max-width, 92%);
}

.chat-message.system {
  align-self: flex-start;
}

.chat-message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.avatar {
  width: 40px;
  height: 40px;
  background: #eee;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #555;
  flex-shrink: 0;
}

.bubble {
  background: var(--bubble-bg-system);
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  font-size: 16px;
  line-height: 1.5;
  border: 1px solid #e0e0e0;
}

.chat-message.user .bubble {
  background: var(--bubble-bg-user);
  border: none;
}

.privacy-note {
  margin: -2px 0 0;
  padding: 0 14px;
  text-align: center;
  color: rgba(26, 26, 26, 0.58);
  font-size: 11px;
  line-height: 1.4;
  letter-spacing: 0.02em;
  align-self: center;
  max-width: 92%;
}

.input-area {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 14px 16px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
  background: #f5f5f6;
  display: flex;
  gap: 14px;
  align-items: center;
  z-index: 100;
  box-sizing: border-box;
}

#name-input {
  flex: 1;
  height: 72px;
  padding: 0 28px;
  border: 1px solid #cfd1d6;
  border-radius: 22px;
  background: #d8d9dd;
  outline: none;
  font-size: 1.2rem;
  color: #2a2a2a;
  font-weight: 600;
  box-sizing: border-box;
}

#name-input::placeholder {
  color: #4c4c4c;
  opacity: 0.9;
}

.send-btn {
  height: 72px;
  min-width: 116px;
  padding: 0 30px;
  border-radius: 22px;
  background: #050812;
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}

/* Water Animation Step 9 */
.water-animation-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #fcfcfc;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  z-index: 100;
}

.water-ink-bg {
  position: absolute;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at center, rgba(33, 150, 243, 0.1) 0%, rgba(33, 150, 243, 0.4) 30%, rgba(3, 169, 244, 0.8) 60%, #01579b 100%);
  opacity: 0;
  transform: scale(0.5);
  animation: water-spread 3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.water-text {
  position: relative;
  font-family: "Kaiti", "STKaiti", serif;
  font-size: 2rem;
  color: white;
  z-index: 2;
  opacity: 0;
  animation: fade-in-text 1.5s ease 1s forwards;
  text-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

@keyframes water-spread {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: scale(1.5);
  }
}

@keyframes fade-in-text {
  to { opacity: 1; transform: translateY(-20px); }
}

/* Gender Selection */
.gender-selection {
  display: flex;
  gap: 20px;
  padding: 30px;
  width: 100%;
  justify-content: center;
}

.gender-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 15px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  width: 80px;
}

.gender-option:active {
  background: #f0f0f0;
}

.gender-img {
  width: 50px;
  height: 50px;
  border-radius: 8px;
  object-fit: contain;
}

/* Wheel & Location */
.wheel-container, .location-selection {
  width: 100%;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding-bottom: 40px;
}

.primary-btn {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 12px 30px;
  border-radius: 30px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
}

.location-btn {
  background: white;
  border: 1px solid var(--primary-color);
  color: var(--primary-color);
  padding: 12px 40px;
  border-radius: 30px;
  font-size: 16px;
  width: 80%;
}

/* MBTI Selection */
.mbti-container {
    width: 100%;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding-bottom: 40px;
}

.mbti-dimensions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 15px;
}

.mbti-row {
    display: flex;
    background: #f5f5f5;
    border-radius: 12px;
    padding: 4px;
    gap: 4px;
    /* justify-content: space-between; */
}

.mbti-opt {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 4px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    /* border: 1px solid #ddd; removed */
    max-width: none;
}

.mbti-opt:active {
    transform: scale(0.95);
    background: #e0e0e0;
}

.mbti-opt.selected {
    background: white;
    color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    font-weight: bold;
}

.mbti-letter {
    font-size: 1.2rem;
    font-weight: bold;
    font-family: sans-serif;
    line-height: 1;
}

.mbti-desc {
    font-size: 0.75rem;
    margin-top: 2px;
    opacity: 0.7;
}

.mbti-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    width: 100%;
}

.secondary-btn {
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 12px 30px;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
}

/* Step 7: End Animation */
.end-animation {
  font-size: 2rem;
  color: var(--ink-color);
  animation: fade-in-out 3s forwards;
}

@keyframes fade-in-out {
  0% { opacity: 0; }
  20% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* Main Screen (Old Info Card) */
.info-card {
  background: white;
  padding: 20px;
  border-radius: 12px;
  margin-top: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.info-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #eee;
}

.info-row:last-child {
  border-bottom: none;
}

/* Step 8 Main Interface */
.main-interface {
    background-color: #fcf9f2; /* Solid background to cover body's NorDi.png */
    position: relative;
    /* Ensure content is above background */
}

/* Pseudo-element for Opacity Background */
.main-interface::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('images/DatDi.png') no-repeat center center fixed;
    background-size: cover;
    opacity: 0.3;
    z-index: 0;
    pointer-events: none;
}

.main-content {
    flex: 1;
    overflow-y: hidden; /* Prevent scrolling */
    width: 100%;
    max-width: 100%;
    padding: 8px 10px 6px;
    z-index: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    height: 100vh; /* Force full height */
    box-sizing: border-box;
    justify-content: space-between; /* Distribute space */
}

.date-header-card {
    background: rgba(255, 255, 255, 0.3); /* More transparent */
    border-radius: 16px;
    padding: 10px 15px; /* Further reduced padding */
    margin-bottom: 5px; /* Reduced margin */
    width: 100%;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(2px); /* Reduced blur */
    flex-shrink: 0;
}

.date-left-big {
    font-size: 2.5rem; /* Reduced slightly */
    font-weight: 300;
    color: #333;
    font-family: 'Roboto', sans-serif;
    line-height: 1;
}

.date-right-info {
    text-align: right;
    font-size: 0.8rem; /* Smaller font to prevent wrapping */
    color: #555;
    white-space: nowrap; /* Prevent wrapping */
    line-height: 1.4;
}

.date-lunar {
    font-family: 'KaiTi', 'STKaiti', serif;
    font-size: 0.95rem; /* Slightly larger for emphasis */
    color: #222;
    margin-bottom: 2px;
}

/* ... existing styles ... */

.daily-card-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px; /* Reduced gap */
    flex: 1;
    justify-content: center; /* Center content vertically */
    padding-bottom: 10px; /* Reduced padding */
}

.score-container {
    width: 180px; /* Reduced size */
    height: 180px; /* Reduced size */
    background: url('images/NumDi.png') no-repeat center center;
    background-size: contain;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #fff;
    margin-top: 5px; /* Reduced margin */
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
    flex-shrink: 0;
}

.score-label {
    font-size: 1rem; /* Reduced font */
    font-weight: 500;
    margin-bottom: 2px;
    color: #fff;
    letter-spacing: 2px;
}

.score-value {
    font-size: 2.2rem; /* Reduced font */
    font-weight: bold;
    line-height: 1;
    color: #fff;
}

/* Loading Overlay - Absolute Position */
.loading-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    pointer-events: none; /* Allow seeing through */
}

.loading-text {
    margin-top: 15px;
    font-size: 1rem;
    color: #333;
    font-weight: bold;
    background: rgba(255,255,255,0.9);
    padding: 8px 15px;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    backdrop-filter: blur(5px);
}

.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border-left-color: #d9534f;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Bottom Info Card Wrapper */
.bottom-info-card {
    background: rgba(255, 255, 255, 0.3); /* More transparent */
    border-radius: 20px;
    padding: 10px; /* Further reduced padding */
    width: 100%;
    backdrop-filter: blur(2px); /* Reduced blur */
    box-shadow: 0 4px 10px rgba(0,0,0,0.03);
    margin-top: 5px;
    margin-bottom: 5px; /* Further reduced margin */
    flex-shrink: 0;
}

.almanac-container {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    margin-bottom: 5px; /* Reduced margin */
    border-bottom: 1px solid rgba(0,0,0,0.05);
    padding-bottom: 5px; /* Reduced padding */
}

.almanac-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.almanac-list {
    list-style: none;
    margin: 0;
    padding: 0;
    width: 100%;
    display: grid;
    gap: 4px;
}

.almanac-list li {
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9rem;
    line-height: 1.25;
    color: #3f3f3f;
}

.almanac-circle {
    width: 36px; /* Further reduced size */
    height: 36px; /* Further reduced size */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.9rem;
    font-weight: bold;
    margin-bottom: 3px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* ... existing styles ... */

/* Specific Colors for Yi/Ji Circles */
.circle-yi {
    background-color: #4caf50; /* Green */
}

.circle-ji {
    background-color: #f44336; /* Red */
}

.quote-container {
    text-align: center;
    padding-top: 5px; /* Reduced padding */
}

.quote-text {
    font-family: "KaiTi", "STKaiti", serif;
    font-size: 1.2rem; /* Reduced font */
    color: #333;
    line-height: 1.3;
    font-weight: bold;
    text-shadow: 0 1px 1px rgba(255,255,255,0.8);
}

.footer-action {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 5px; /* Reduced margin */
    flex-shrink: 0;
}

.expand-detail-btn {
    background: #111;
    color: white;
    border: none;
    padding: 12px 0; /* Reduced padding */
    width: 100%;
    border-radius: 12px;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

/* GanZhi Circles */
.ganzhi-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  color: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* Five Elements Colors */
.bg-wood { background-color: #4caf50; } /* Green */
.bg-fire { background-color: #f44336; } /* Red */
.bg-earth { background-color: #ff9800; } /* Orange/Brown */
.bg-metal { background-color: #9e9e9e; } /* Grey/Gold */
.bg-water { background-color: #2196f3; } /* Blue */

/* Modal Styles */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  justify-content: center;
  align-items: flex-end; /* Bottom sheet on mobile? Or center? User said "new interface", let's do full screen or large modal */
}

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

.modal-content.full-screen {
  width: 100%;
  height: 100%; /* Full screen */
  background: #fcf9f2;
  display: flex;
  flex-direction: column;
  animation: slide-up 0.3s ease-out;
}

@keyframes slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  padding: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #e0e0e0;
  background: white;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.2rem;
  color: #333;
}

.modal-close {
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  color: #999;
}

.modal-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  font-size: 1rem;
  line-height: 1.8;
  color: #333;
  white-space: pre-wrap; /* Preserve formatting */
}
