:root {
    /* Color Palette - Traditional Chinese (Light Theme) */
    --gold-primary: #D4AF37;
    --gold-light: #F4E4BC;
    --gold-dark: #B8941E;
    --red-primary: #C41E3A;
    --red-dark: #8B0000;
    --blue-primary: #1E88E5;
    --blue-dark: #1565C0;
    --blue-medium: #1976D2;
    --blue-light: #42A5F5;
    --bg-light: #F5F5F5;
    --bg-card: rgba(255, 255, 255, 0.95);
    --text-primary: #212121;
    --text-secondary: #757575;
    --shadow-glow: rgba(212, 175, 55, 0.3);

    /* Typography */
    --font-serif: 'Noto Serif SC', serif;
    --font-sans: 'Noto Sans', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background: linear-gradient(135deg, #FFFFFF 0%, #F5F5F5 50%, #FFFFFF 100%);
    color: var(--text-primary);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* Decorative Background */
.background-pattern {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('data:image/svg+xml,%3Csvg width="60" height="60" xmlns="http://www.w3.org/2000/svg"%3E%3Cpath d="M30 0L35 25L30 30L25 25Z M60 30L35 35L30 30L35 25Z M30 60L25 35L30 30L35 35Z M0 30L25 25L30 30L25 35Z" fill="%23D4AF37" opacity="0.03"/%3E%3C/svg%3E');
    background-image:
        radial-gradient(circle at 20% 30%, rgba(212, 175, 55, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(196, 30, 58, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    position: relative;
    z-index: 1;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
}

.header-decoration {
    width: 100px;
    height: 4px;
    background: linear-gradient(90deg, transparent, var(--gold-primary), transparent);
    margin: 0 auto 1.5rem;
    border-radius: 2px;
}

.title {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.title-main {
    font-family: var(--font-serif);
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--gold-primary), var(--gold-light), var(--gold-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.15em;
    text-shadow: 0 0 30px var(--shadow-glow);
}

.title-sub {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    color: var(--text-secondary);
    letter-spacing: 0.2em;
}

.subtitle {
    margin-top: 1rem;
    font-size: 1.1rem;
    color: var(--text-secondary);
}

/* Introduction Section */
.intro-section {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 20px;
    padding: 3rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.coins-visual {
    text-align: center;
    margin-bottom: 2rem;
}

.coin-display {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin: 2rem 0;
}

.coin-item {
    perspective: 1000px;
}

.coin-face {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gold-dark), var(--gold-primary), var(--gold-light));
    border: 3px solid var(--gold-dark);
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.3);
    position: relative;
    animation: float 3s ease-in-out infinite;
}

.coin-face::before {
    content: '福';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-serif);
    font-size: 2rem;
    font-weight: 700;
    color: var(--red-primary);
}

.coin-item:nth-child(2) .coin-face {
    animation-delay: 0.5s;
}

.coin-item:nth-child(3) .coin-face {
    animation-delay: 1s;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* Instruction Box */
.instruction-box {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 15px;
    padding: 2rem;
    margin-bottom: 2rem;
}

.instruction-box h2 {
    color: var(--gold-primary);
    margin-bottom: 1.5rem;
    font-family: var(--font-serif);
    font-size: 1.5rem;
}

.instructions {
    list-style: none;
    counter-reset: step-counter;
    margin-bottom: 2rem;
}

.instructions li {
    counter-increment: step-counter;
    margin-bottom: 1rem;
    padding-left: 3rem;
    position: relative;
    line-height: 1.8;
}

.instructions li::before {
    content: counter(step-counter);
    position: absolute;
    left: 0;
    top: 0;
    width: 2rem;
    height: 2rem;
    background: linear-gradient(135deg, var(--gold-primary), var(--gold-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.line-rules {
    background: rgba(212, 175, 55, 0.15);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 10px;
    padding: 1.5rem;
    margin-top: 1.5rem;
}

.line-rules h3 {
    color: var(--gold-primary);
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.rule-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.rule-item {
    background: rgba(255, 255, 255, 0.8);
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.rule-item.moving {
    border-color: var(--red-primary);
    background: rgba(196, 30, 58, 0.1);
}

.coin-combo {
    font-size: 1.5rem;
    text-align: center;
}

.line-result {
    text-align: center;
    font-size: 0.9rem;
}

.note {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 0.5rem;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-toss {
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: var(--font-sans);
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--gold-primary), var(--gold-dark));
    color: #000;
    box-shadow: 0 4px 20px var(--shadow-glow);
    width: 100%;
    margin-top: 1rem;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 30px var(--shadow-glow);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 2px solid var(--gold-primary);
}

.btn-secondary:hover {
    background: rgba(212, 175, 55, 0.2);
    transform: translateY(-2px);
}

.btn-toss {
    background: linear-gradient(135deg, var(--red-primary), var(--red-dark));
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 2rem auto;
    box-shadow: 0 4px 20px rgba(196, 30, 58, 0.4);
}

.btn-toss:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 30px rgba(196, 30, 58, 0.6);
}

.btn-toss:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-icon {
    font-size: 1.5rem;
}

/* Sections */
.divination-section,
.results-section {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(212, 175, 55, 0.3);
    border-radius: 20px;
    padding: 3rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    margin-top: 2rem;
}

.hidden {
    display: none;
}

/* Input Area */
.input-area {
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--gold-primary);
    font-weight: 600;
}

.form-group textarea {
    width: 100%;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid rgba(212, 175, 55, 0.4);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 1rem;
    resize: vertical;
}

.form-group textarea:focus {
    outline: none;
    border-color: var(--gold-primary);
    box-shadow: 0 0 15px var(--shadow-glow);
}

.gender-select {
    display: flex;
    gap: 1.5rem;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.radio-label input[type="radio"] {
    width: 20px;
    height: 20px;
    accent-color: var(--gold-primary);
}

/* Progress Tracker */
.progress-tracker {
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 15px;
    padding: 2rem;
    margin-bottom: 2rem;
}

.progress-tracker h3 {
    color: var(--gold-primary);
    margin-bottom: 1.5rem;
    text-align: center;
}

.progress-steps {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
}

.hero-section {
    text-align: center;
    padding: 4rem 2rem;
    background: rgba(255, 255, 255, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    transition: all 0.3s ease;
}

.step {
    flex: 1;
    text-align: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    transition: all 0.3s ease;
}

.step.active {
    background: linear-gradient(135deg, var(--gold-primary), var(--gold-dark));
    color: #000;
    border-color: var(--gold-primary);
    transform: scale(1.05);
    box-shadow: 0 4px 15px var(--shadow-glow);
}

.step.completed {
    background: rgba(212, 175, 55, 0.2);
    border-color: var(--gold-primary);
}

.progress-text {
    text-align: center;
    margin-top: 1rem;
    color: var(--text-secondary);
}

/* Coin Area */
.coin-area {
    text-align: center;
    padding: 2rem;
}

.coin-container {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin: 2rem 0;
    min-height: 120px;
}

.coin {
    perspective: 1000px;
}

.coin-inner {
    width: 100px;
    height: 100px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.coin.flipping .coin-inner {
    animation: flip 1.5s ease-in-out;
}

@keyframes flip {
    0% {
        transform: rotateY(0deg) rotateX(0deg);
    }

    25% {
        transform: rotateY(180deg) rotateX(90deg);
    }

    50% {
        transform: rotateY(360deg) rotateX(180deg);
    }

    75% {
        transform: rotateY(540deg) rotateX(270deg);
    }

    100% {
        transform: rotateY(720deg) rotateX(360deg);
    }
}

.coin-front,
.coin-back {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-serif);
    font-size: 2.5rem;
    font-weight: 700;
    border: 4px solid var(--gold-dark);
    box-shadow:
        0 4px 15px rgba(0, 0, 0, 0.4),
        inset 0 2px 6px rgba(255, 255, 255, 0.3);
}

.coin-front {
    background: linear-gradient(135deg, var(--gold-dark), var(--gold-primary), var(--gold-light));
    color: var(--red-primary);
}

.coin-front::before {
    content: '福';
}

.coin-back {
    background: linear-gradient(135deg, #8B7355, #A0826D, #C9A982);
    transform: rotateY(180deg);
}

.toss-result {
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--gold-primary);
    font-weight: 600;
    margin: 1.5rem 0;
}

/* Hexagram Display */
.hexagram-display {
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    line-height: 1.8;
}

.hexagram-display h3 {
    color: var(--gold-primary);
    text-align: center;
    margin-bottom: 2rem;
    font-size: 1.5rem;
}

.hexagrams-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 3rem;
    flex-wrap: wrap;
}

.hexagram-box {
    text-align: center;
}

.hexagram-box h4 {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.hexagram {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 1.5rem auto;
}

.hexagram-line {
    height: 10px;
    width: 150px;
    /* Increased for better visibility */
    background: var(--blue-primary);
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    position: relative;
    transition: all 0.3s ease;
}

/* Moving lines are RED */
/* --- SỬA LỖI HIỂN THỊ HÀO ÂM ĐỘNG --- */

/* 1. Logic chung cho hào động (giữ nguyên hoặc sửa nhẹ) */
.hexagram-line.moving {
    background: var(--red-primary) !important; 
    box-shadow: 0 0 15px rgba(196, 30, 58, 0.5);
}

/* 2. QUAN TRỌNG: Ghi đè lại cho Hào Âm (Yin) */
/* Khi hào Âm động, nền của div cha phải trong suốt để thấy khoảng hở */
.hexagram-line.yin.moving {
    background: transparent !important; 
    box-shadow: none; /* Bỏ bóng của div cha, chỉ giữ bóng của 2 vạch con */
}

/* 3. Tô màu đỏ cho 2 vạch con của hào Âm */
.hexagram-line.yin.moving::before,
.hexagram-line.yin.moving::after {
    background: var(--red-primary) !important;
    box-shadow: 0 0 15px rgba(196, 30, 58, 0.5);
}

.hexagram-line.yin {
    background: none;
    display: flex;
    justify-content: space-between;
    width: 150px;
    /* Same width as Yang lines */
}

.hexagram-line.yin::before,
.hexagram-line.yin::after {
    content: '';
    width: 68px;
    /* Fixed width: (150px - 12px gap) / 2 = 69px per segment */
    height: 10px;
    background: var(--blue-primary);
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

/* Yin moving lines are also RED */
.hexagram-line.yin.moving::before,
.hexagram-line.yin.moving::after {
    background: var(--red-primary) !important;
    box-shadow: 0 0 15px rgba(196, 30, 58, 0.5);
}


/* Removed star decoration - was causing overlap */

.hexagram-arrow {
    font-size: 2rem;
    color: var(--gold-primary);
}

.hexagram-name {
    color: var(--gold-primary);
    font-family: var(--font-serif);
    font-size: 1.3rem;
    font-weight: 600;
    margin-top: 1rem;
}

/* Results Section */
.results-section h2 {
    color: var(--gold-primary);
    text-align: center;
    font-family: var(--font-serif);
    font-size: 2rem;
    margin-bottom: 2rem;
}

.time-info {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(255, 250, 240, 0.95));
    border: 1px solid rgba(212, 175, 55, 0.4);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.05);
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-primary);
}

.time-info strong {
    color: var(--gold-dark);
    font-weight: 700;
    display: inline-block;
}

/* Tables */
.tables-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.table-wrapper {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 15px;
    padding: 2rem;
}

.table-wrapper h3 {
    color: var(--gold-primary);
    text-align: center;
    font-family: var(--font-serif);
    margin-bottom: 0.5rem;
}

.hexagram-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.hexagram-table,
.detail-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.hexagram-table th,
.hexagram-table td,
.detail-table th,
.detail-table td {
    padding: 0.5rem 0.2rem;
    border: 1px solid rgba(212, 175, 55, 0.3);
    text-align: center;
    font-size: 0.95rem;
}

.hexagram-table th,
.detail-table th {
    background: rgba(212, 175, 55, 0.2);
    color: var(--gold-primary);
    font-weight: 600;
}

.hexagram-table td,
.detail-table td {
    background: rgba(255, 255, 255, 0.95);
}

.hexagram-table .moving-line,
.detail-table .moving-line {
    color: var(--red-primary);
    font-weight: 600;
}

/* Prompt Section */
.prompt-section {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 15px;
    padding: 2rem;
    margin-bottom: 2rem;
}

.prompt-section h3 {
    color: var(--gold-primary);
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.btn-copy {
    background: linear-gradient(135deg, var(--blue-medium), var(--blue-light));
    color: var(--text-primary);
    border: none;
    padding: 0.5rem 1.5rem;
    border-radius: 25px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-copy:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(57, 73, 171, 0.4);
}

.prompt-box {
    background: rgba(245, 245, 245, 0.95);
    border: 2px solid rgba(212, 175, 55, 0.4);
    border-radius: 10px;
    padding: 1.5rem;
    max-height: 500px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    white-space: pre-wrap;
    color: #424242;
}

.prompt-box::-webkit-scrollbar {
    width: 8px;
}

.prompt-box::-webkit-scrollbar-track {
    background: rgba(200, 200, 200, 0.3);
    border-radius: 4px;
}

.prompt-box::-webkit-scrollbar-thumb {
    background: var(--gold-primary);
    border-radius: 4px;
}

/* Loading Animation - Bagua (Eight Trigrams) */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-overlay.active {
    display: flex;
}

.bagua-spinner {
    width: 120px;
    height: 120px;
    position: relative;
    animation: spin 3s linear infinite;
}

.bagua-spinner::before {
    content: '☰☷☳☴☵☶☱☲';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    color: var(--gold-primary);
    text-shadow: 0 0 20px var(--shadow-glow);
    letter-spacing: -0.5rem;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loading-text {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--gold-dark);
    font-weight: 600;
    white-space: nowrap;
}

/* AI Quick Links */
.ai-quick-links {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    align-items: center;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.5);
    padding: 0.8rem;
    border-radius: 10px;
}

.ai-links-label {
    font-weight: 600;
    color: var(--text-secondary);
    margin-right: 0.5rem;
    font-size: 0.9rem;
}

.ai-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.8rem;
    background: white;
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 20px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.ai-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border-color: var(--gold-primary);
    color: var(--gold-dark);
    text-decoration: none;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .title-main {
        font-size: 2rem;
    }

    .title-sub {
        font-size: 1rem;
    }

    .intro-section,
    .divination-section,
    .results-section {
        padding: 1.5rem;
    }

    .coin-display {
        gap: 1rem;
    }

    .coin-face {
        width: 60px;
        height: 60px;
    }

    .coin-face::before {
        font-size: 1.5rem;
    }

    .progress-steps {
        flex-wrap: wrap;
    }

    .step {
        flex-basis: calc(33.333% - 0.5rem);
        padding: 0.75rem 0.5rem;
        font-size: 0.9rem;
    }

    .coin-container {
        gap: 1.5rem;
    }

    .coin-inner {
        width: 70px;
        height: 70px;
    }

    .coin-front::before {
        font-size: 1.8rem;
    }

    .tables-container {
        grid-template-columns: 1fr;
    }

    .hexagrams-container {
        flex-direction: column;
        gap: 2rem;
    }

    .hexagram-arrow {
        transform: rotate(90deg);
    }
}