body {
    font-family: Arial, sans-serif;
    margin: 2rem auto; /* Original body margin for overall page centering */
    padding: 20px;
    background-color: #f4f6f8;
    color: #333;
    /* Removed display: flex, justify-content, align-items, min-height from body */
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: #fff;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Specific wrapper for PREVIEW.HTML content - ensure this remains for preview.html */
#main-content-wrapper { /* This ID will be used in preview.html only */
    width: 100%;
    max-width: 450px; /* Width optimized for preview.html's payment UI and report */
    padding: 20px;
    box-sizing: border-box;
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin: 2rem auto;
}

/* REMOVED #index-page-wrapper style block as it's no longer needed */

form {
    background: #fff; /* Original form background */
    padding: 20px; /* Reduced padding for tighter fit */
    border-radius: 10px; /* Original form border-radius */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); /* Original form box-shadow */
    width: fit-content; /* Make form wrap around content */
    margin: 0 auto; /* Center the form */
}
/* Reverting form .form-group padding as original form has its own padding */
form .form-group {
    /* No padding here, let the form's padding handle it */
    padding: 0;
}


h1 {
    color: #1e88e5;
    text-align: center;
    /* Reverted to original margin for h1 as it's global again */
    margin: 0 auto 20px auto; /* Centered with bottom margin */
}
/* Removed #main-content-wrapper h1 specific rule */


h3 {
    text-align: center;
}

p {
    font-size: 0.85rem;
    /* Reverted to original margin for p as it's global again */
    margin-bottom: 15px;
    /* text-align: center; (optional, but likely original behavior) */
}

.button-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 15px; /* Increased margin for better spacing */
    flex-wrap: wrap;
    margin-bottom: 8px;
    width: 100%; /* Ensure button row takes full width of form */
}

/* Core button styles - applied universally to primary buttons and fasttrack button */
button,
.fasttrack-button,
.custom-message-box-ok {
    padding: 10px 20px;
    font-size: 16px;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    text-align: center;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    width: 200px;
    transition: background-color 0.3s ease, transform 0.3s ease;
    margin: 5px; /* Adjust margin around buttons if needed */
    text-decoration: none;
    box-sizing: border-box;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Default active button color (applies to standard buttons, not 'back') */
button:not(.back):not(.custom-message-box-ok) {
    background-color: #007bff;
    color: white;
}

/* Custom message box OK button style */
.custom-message-box-ok {
    background-color: #007bff;
    color: white;
    width: auto;
    padding: 10px 20px;
    margin-top: 20px;
}


/* Back button specific style */
button.back {
    background-color: #6c757d;
    color: white;
}

/* Hover state for all active buttons */
button:not(:disabled):hover,
.fasttrack-button:not(.disabled):hover,
.custom-message-box-ok:hover {
    background-color: #0056b3;
    transform: translateY(-1px);
}

/* FastTrack button specific active state */
.fasttrack-button:not(.disabled) {
    background-color: #28a745;
    color: white;
}

/* Disabled state for all buttons */
button:disabled,
.fasttrack-button.disabled {
    background-color: #cccccc;
    color: #666666;
    cursor: not-allowed;
    border: none;
    box-shadow: none;
    opacity: 0.6;
    pointer-events: none;
    transform: none;
}

/* Start report button styling (matching home page button) */
.start-report-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #1e88e5;
    color: white;
    padding: 18px 40px;
    border-radius: 50px;
    text-decoration: none;
    font-size: 1.2em;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
    position: relative;
    overflow: hidden;
    border: none;
    cursor: pointer;
    line-height: 1;
    text-align: center;
}

.start-report-btn:hover {
    background: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(102, 126, 234, 0.4);
}

.start-report-btn:disabled {
    background-color: #cccccc !important;
    color: #666666 !important;
    cursor: not-allowed !important;
    box-shadow: none !important;
    opacity: 0.6 !important;
    pointer-events: none !important;
    transform: none !important;
}

.start-report-btn:disabled:hover {
    background-color: #cccccc !important;
    color: #666666 !important;
    cursor: not-allowed !important;
    box-shadow: none !important;
    opacity: 0.6 !important;
    pointer-events: none !important;
    transform: none !important;
}

/* Ensure YouTube membership verification button text matches generate report button */
.google-login-btn {
    font-size: 1.2em;
    font-weight: bold;
    width: 200px;       /* Match button default width */
    height: 40px;       /* Match button default height */
    padding: 0;         /* Prevent extra height from padding */
}

@media (max-width: 768px) {
    .start-report-btn {
        padding: 12px 18px;
        font-size: 1em;
        border-radius: 30px;
    }
}

.step {
    display: none;
}

.step.active {
    display: block;
}

.progress-bar {
    height: 10px;
    background: #ddd;
    border-radius: 5px;
    margin-bottom: 20px;
    overflow: hidden;
    width: 344px; /* Match form width (304px selectors + 40px padding) */
    margin-left: auto;
    margin-right: auto;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: #007bff;
    transition: width 0.3s ease;
}

.form-row {
    display: flex;
    /* Reverted to original display: flex from the provided screenshot */
    align-items: center; /* Align items to center */
    gap: 12px; /* Original gap */
    margin-bottom: 8px;
    /* Removed flex-wrap here to respect original behavior for form rows */
}

.form-row label {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

select {
    /* Reverted to original select styling */
    padding: 4px 6px;
    font-size: 12px;
    width: 10rem auto; /* Reverted to original width */
    margin-bottom: 12px; /* Original margin */
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #fff;
}

.zodiac-icon-inline {
    font-size: 24px;
    margin-left: 10px;
    text-align: center;
    display: block;
    margin-top: 15px;
}

label {
    display: inline-block;
    margin: 8px 12px 4px 0;
}

input[type="date"],
input[type="text"] {
    /* Reverted to original input styling */
    width: 10rem auto;
    padding: 10px;
    margin-bottom: 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

input[type="radio"] {
    margin-right: 6px;
}

#loading {
    display: none;
    text-align: center;
    font-weight: bold;
    margin-top: 20px;
    color: #555;
}

.hidden {
    display: none;
}

/* NEW CSS for left alignment (consolidated from form-group and step h2) */
.form-group {
    margin-bottom: 8px; /* Reduced from 12px to make form more compact */
    text-align: left;
}

.step h2 {
    text-align: left;
}

/* Admin specific styles */
#admin-results-container {
    margin-top: 30px;
    padding: 20px;
    background-color: #e9f7ef;
    border: 1px solid #c3e6cb;
    border-radius: 8px;
    display: none;
}

#admin-report-preview {
    white-space: pre-wrap;
    border: 1px solid #b3d7ff;
    padding: 15px;
    margin-top: 15px;
    background-color: #f0f8ff;
    border-radius: 5px;
    max-height: 400px;
    overflow-y: auto;
}

/* Styles for #admin-download-link (if still used) - adjusted to match button styles */
#admin-download-link {
    display: inline-flex;
    margin-top: 15px;
    background-color: #007bff;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    height: 40px;
    width: 200px;
    justify-content: center;
    align-items: center;
}

#admin-download-link:hover {
    background-color: #0056b3;
}


/* Styles for preview.html that were previously inline (now moved here) */
#report {
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 60vh;
    overflow-y: auto;
    border: 1px solid #ccc;
    padding: 1em;
    display: none;
}
#report-text {
    white-space: pre-wrap;
    word-break: break-word;
    padding: 0;
    margin: 0;
    border: none;
}

#payment-container {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    flex-wrap: wrap;
    max-width: 100%; /* Allows it to take up to 100% of #main-content-wrapper's width in preview.html */
}

#payment-element-wrapper {
    max-width: 360px;
    flex-grow: 1;
}

#download-btn {
    margin-top: 20px;
    display: none;
}

#success-message {
    color: green;
    margin-top: 15px;
    display: none;
}

#back-btn {
    display: none;
    margin-top: 10px;
}

#price-display {
    font-size: 1.0em;
    font-weight: bold;
    margin-bottom: 10px;
    color: #333;
    text-align: center;
}

/* Loading Overlay CSS */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.0);
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 99999;
    text-align: center;
    font-size: 1.2em;
    color: #333;
}

.loading-content {
    padding: 30px;
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

#loading-image {
    max-width: 150px;
    height: auto;
    margin-bottom: 20px;
}

#loading-message {
    width: 100%;
    overflow: hidden;
    background: #fff;
    border-radius: 6px;
    border: 1px solid #eee;
    height: 2.5em;
    position: relative;
    display: flex;
    align-items: center;
}
#loading-message .marquee {
    display: inline-block;
    white-space: nowrap;
    /* The padding-left property is removed */
    animation: marquee-left 10s linear infinite;
    font-size: 1.2em;
    line-height: 2.5em;
    color: #0e7ad8;
    font-weight: bold;
}

@keyframes marquee-left {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}
#loading-message:hover .marquee {
    animation-play-state: paused;
}

/* Add this new rule to style.css */
#loading-secondary-message {
  font-size: 0.85em;
  color: #555;
  margin-top: 15px;
  font-weight: normal;
  white-space: pre-line; 
}
/* Styles for the status message and reports delivered message */
/* NEW: #intro-message styling for index.html */
#status-message, #reports-delivered-message {
  background-color: #e6f7ff;
  border: 1px solid #91d5ff;
  color: #004085;
  padding: 10px 20px;
  margin-top: 15px;
  margin-bottom: 20px;
  border-radius: 8px;
  font-size: 0.85em;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  text-align: left;
  width: 344px; /* Match total form width (304px selectors + 40px form padding) */
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box; /* Include padding in width calculation */
}

/* On preview.html, make the status message match the main content width */
#main-content-wrapper #status-message {
  width: 100%;
  max-width: 100%;
}
#status-message {
    display: none;
}
#reports-delivered-message {
    display: block;
}
#intro-message {
    display: block; /* Ensure it's block by default */
}


/* Styles for the top action buttons (Download & Share) */
#final-report-actions {
    margin-top: 20px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    justify-content: center;
    padding: 15px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    border: 1px solid #dee2e6;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* New action button styling */
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  color: white;
  background: #6c757d;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  width: 200px; /* CHANGE: Use a fixed width instead of min-width */
  box-sizing: border-box;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.action-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.action-btn.primary {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
}

.action-btn.primary:hover {
    background: linear-gradient(135deg, #0056b3 0%, #004085 100%);
}

/* Individual button colors */
.action-btn:nth-child(1) { /* Download */
    background: linear-gradient(135deg, #28a745 0%, #1e7e34 100%);
}

.action-btn:nth-child(1):hover {
    background: linear-gradient(135deg, #1e7e34 0%, #155724 100%);
}

.action-btn:nth-child(2) { /* Share */
    background: linear-gradient(135deg, #6f42c1 0%, #5a2d91 100%);
}

.action-btn:nth-child(2):hover {
    background: linear-gradient(135deg, #5a2d91 0%, #4a1d7a 100%);
}

.action-btn:nth-child(3) { /* Copy Link */
    background: linear-gradient(135deg, #fd7e14 0%, #e55a00 100%);
}

.action-btn:nth-child(3):hover {
    background: linear-gradient(135deg, #e55a00 0%, #cc4a00 100%);
}

.action-btn:nth-child(4) { /* QR Code */
    background: linear-gradient(135deg, #20c997 0%, #17a2b8 100%);
}

.action-btn:nth-child(4):hover {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
}

/* SVG icon styling */
.action-btn svg {
    flex-shrink: 0;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

/* Responsive design */
@media (max-width: 768px) {
    /* General mobile optimizations */
    body {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 10px;
    }
    
    h1 {
        font-size: 1.5em;
        margin-bottom: 15px;
    }
    
    #intro-message p {
        font-size: 0.9em;
        line-height: 1.4;
    }
    
    /* Form container */
    #index-page-wrapper {
        max-width: 100%;
        padding: 0;
    }
    
    /* Preview page specific mobile optimizations */
    #main-content-wrapper {
        max-width: 100%;
        padding: 0;
    }
    
    /* Payment container mobile optimization */
    #payment-container {
        margin: 15px 0;
    }
    
    #payment-element-wrapper {
        padding: 15px;
        border-radius: 8px;
    }
    
    #price-display {
        font-size: 1.2em;
        margin-bottom: 10px;
        text-align: center;
    }
    
    #promo-note {
        text-align: center;
        font-size: 0.9em;
        margin-bottom: 15px !important;
    }
    
    #countdown-timer {
        display: block;
        margin-top: 8px;
        font-size: 0.8em;
    }
    
    /* Payment element container */
    #payment-element {
        margin: 15px 0;
    }
    
    /* Report display mobile optimization */
    #report {
        margin: 15px 0;
        padding: 15px;
        border-radius: 8px;
        background: #f8f9fa;
    }
    
    #report-text {
        font-size: 14px;
        line-height: 1.6;
        white-space: pre-wrap;
        word-wrap: break-word;
        overflow-wrap: break-word;
        max-width: 100%;
    }
    
    /* Status messages */
    #status-message, #reports-delivered-message {
        font-size: 14px;
        padding: 12px;
        margin: 10px 0;
        border-radius: 6px;
        text-align: center;
    }
    
    /* Loading overlay mobile optimization */
    #loading-overlay {
        padding: 20px;
    }
    
    .loading-content {
        padding: 30px 20px;
        border-radius: 12px;
        max-width: 90vw;
        text-align: center;
    }
    
    #loading-image {
        max-width: 80px;
        height: auto;
        margin-bottom: 15px;
    }
    
    #loading-message {
        font-size: 16px;
        line-height: 1.4;
    }
    
    /* DOB Row mobile optimization */
    .dob-row-fields {
        flex-direction: column !important;
        gap: 20px !important;
        width: 100% !important;
        margin-left: 0 !important;
        align-items: flex-start !important;
    }
    
    .dob-row-fields .dob-field-group:has(#dobTypeSelect) {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
    }
    
    .dob-row-fields .dob-field-group:has(#dobTypeSelect) .dob-vertical-label {
        margin-bottom: 0 !important;
        margin-right: 0 !important;
        font-size: 16px !important;
        font-weight: bold !important;
    }
    
    .dob-row-fields .dob-field-group:has(#dobTypeSelect) #dobTypeSelect {
        height: 44px !important; /* Same height as other selectors */
        font-size: 16px !important; /* Same font size as other selectors */
        width: auto !important;
        min-width: 80px !important;
        max-width: 120px !important;
        margin-right: 8px !important; /* Small gap between solar/lunar and year selector */
        display: inline-block !important;
    }
    
    .dob-row-fields #dob-solar-fields,
    .dob-row-fields #dob-lunar-fields {
        display: inline-flex !important;
        flex-wrap: wrap !important;
        gap: 4px !important;
        align-items: center !important;
        width: auto !important;
        justify-content: flex-start !important;
    }
    
    .dob-row-fields .dob-field-group {
        display: flex !important;
        align-items: center !important;
        gap: 2px !important; /* Reduced from 4px to 2px (another 50%) */
        flex-wrap: wrap !important;
        width: 100% !important;
        justify-content: flex-start !important;
    }
    
    .dob-row-fields .hour-gender-group {
        display: flex !important;
        flex-direction: row !important;
        gap: 12px !important;
        align-items: center !important;
        flex-wrap: wrap !important;
        width: 100% !important;
        justify-content: flex-start !important;
    }
    
    .dob-row-fields .dob-vertical-label {
        margin-right: 2px !important; /* Reduced from 4px to 2px (another 50%) */
        white-space: nowrap !important; /* Force single line */
        writing-mode: horizontal-tb !important; /* Override vertical writing mode */
        text-orientation: mixed !important; /* Normal text orientation */
        width: auto !important; /* Let content determine width */
        min-width: auto !important; /* Remove min-width constraint */
        line-height: normal !important; /* Normal line height */
        height: auto !important; /* Auto height */
        display: inline-block !important; /* Inline block for proper spacing */
        /* Additional aggressive overrides */
        text-combine-upright: none !important; /* Disable text combining */
        text-transform: none !important; /* No text transformation */
        word-break: normal !important; /* Normal word breaking */
        overflow-wrap: normal !important; /* Normal overflow wrapping */
        /* Force horizontal layout */
        direction: ltr !important; /* Left to right */
        unicode-bidi: normal !important; /* Normal bidirectional text */
        /* Override any flex properties */
        flex: none !important; /* No flex growth/shrink */
        align-self: auto !important; /* Auto alignment */
        
        /* Force the text content to be horizontal */
        &::before,
        &::after {
          writing-mode: horizontal-tb !important;
          text-orientation: mixed !important;
        }
        
        /* Target any child elements */
        & * {
          writing-mode: horizontal-tb !important;
          text-orientation: mixed !important;
          white-space: nowrap !important;
        }
    }
    
    /* Hide <br> tags in mobile labels to force single line */
    .dob-vertical-label br {
        display: none !important;
    }
    
    /* Ensure only one set of date fields is visible on mobile */
    #dob-lunar-fields {
        display: none !important;
    }
    
    /* When lunar is selected, show lunar and hide solar */
    .dob-row-fields[data-dob-type="lunar"] #dob-solar-fields,
    .dob-row-fields .dob-field-group[data-dob-type="lunar"] #dob-solar-fields {
        display: none !important;
    }
    
    .dob-row-fields[data-dob-type="lunar"] #dob-lunar-fields,
    .dob-row-fields .dob-field-group[data-dob-type="lunar"] #dob-lunar-fields {
        display: inline-flex !important;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    body {
        padding: 8px;
    }
    
    h1 {
        font-size: 1.3em;
    }
    
    /* Preview page small screen optimizations */
    #main-content-wrapper {
        padding: 0;
    }
    
    #payment-element-wrapper {
        padding: 12px;
    }
    
    #price-display {
        font-size: 1.1em;
    }
    
    #promo-note {
        font-size: 0.8em;
    }
    
    #countdown-timer {
        font-size: 0.7em;
    }
    
    #report {
        padding: 12px;
        margin: 10px 0;
    }
    
    #report-text {
        font-size: 13px;
        line-height: 1.5;
    }
    
    .loading-content {
        padding: 20px 15px;
        max-width: 95vw;
    }
    
    #loading-image {
        max-width: 60px;
    }
    
    #loading-message {
        font-size: 14px;
    }
    
    /* Action buttons on small screens */
    .action-btn {
        height: 44px;
        font-size: 14px;
        padding: 8px 12px;
    }
    
    .action-btn svg {
        width: 14px;
        height: 14px;
    }
    
    /* QR Code on small screens */
    #qrcode-container {
        padding: 15px;
    }
    
    #qrcode-container img {
        max-width: 150px;
    }
    
    #qrcode-container p {
        font-size: 12px;
    }
    
    /* Custom message box on small screens */
    .custom-message-box-content {
        margin: 15px;
        padding: 20px 15px;
        max-width: calc(100vw - 30px);
    }
    
    .custom-message-box-ok {
        height: 40px;
        font-size: 14px;
    }
    
    /* Status messages on small screens */
    #status-message, #reports-delivered-message {
        font-size: 13px;
        padding: 10px;
    }
    
    /* DOB Row small screen optimizations */
    .dob-row-fields {
        gap: 16px; /* Slightly reduced but still good spacing */
    }
    
    .dob-field-group {
        gap: 6px;
    }
    
    .hour-gender-group {
        gap: 8px;
    }
    
    .hour-gender-group .dob-field-group {
        flex: 1;
        min-width: 120px; /* Ensure minimum width for readability */
    }
    
    .dob-vertical-label {
        font-size: 14px;
        min-width: 50px;
    }
    
    /* Ensure gender label gap is also reduced on mobile */
    .dob-field-group:has(#gender) .dob-vertical-label,
    .dob-field-group .dob-vertical-label[for="gender"] {
        margin-right: 3px;
    }
    
    #dobTypeSelect {
        min-width: 70px;
        max-width: 100px;
        font-size: 14px !important;
    }
    
    #dob-solar-fields,
    #dob-lunar-fields {
        gap: 2px;
    }
    
    #dob-solar-fields select,
    #dob-lunar-fields select {
        min-width: 50px;
        max-width: 70px;
        font-size: 14px !important;
    }
    
    #dob-solar-fields #gregorianYear,
    #dob-lunar-fields #lunarYear {
        min-width: 70px;
        max-width: 90px;
    }
    
    #dob-solar-fields #gregorianMonth,
    #dob-lunar-fields #lunarMonth {
        min-width: 50px;
        max-width: 70px;
    }
    
    #dob-solar-fields #gregorianDay,
    #dob-lunar-fields #lunarDay {
        min-width: 45px;
        max-width: 60px;
    }
    
    #lunarHour {
        min-width: 70px;
        max-width: 100px !important;
        font-size: 14px !important;
    }
    
    #gender {
        min-width: 50px;
        max-width: 70px !important;
        font-size: 14px !important;
    }
    
    #dob-solar-fields > span,
    #dob-lunar-fields > span {
        text-align: center;
        font-size: 12px;
    }
}

/* Landscape mobile optimization */
@media (max-width: 768px) and (orientation: landscape) {
    .dob-row-fields {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
    }
    
    .dob-vertical-label {
        width: auto;
        min-width: 60px;
    }
    
    #dob-solar-fields,
    #dob-lunar-fields {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }
}

/* Styles for QR Code Container */
#qrcode-container {
    margin-top: 10px;
    text-align: center;
    padding: 10px;
    border: 1px solid #eee;
    border-radius: 5px;
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    display: none;
}
#qrcode-container img {
    max-width: 150px;
    height: auto;
    display: block;
    margin: 0 auto;
}
#qrcode-container p {
    font-size: 0.8em;
    color: #666;
    margin-top: 5px;
}

/* DOB Row Flexbox Layout - Bulletproof, Minimal, Consistent */
#dob-row, .dob-row-fields {
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
.dob-row-fields {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: nowrap !important;
  background: none;
  border-radius: 0;
  box-shadow: none;
  margin-left: 0 !important;
  width: calc(100% + 48px);
  margin-left: -6px !important;
  margin-bottom: 0 !important;
}
.dob-vertical-label {
  display: inline-block;
  white-space: pre-line;
  width: 40px;
  min-width: 40px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: #222;
  margin: 0 6px 0 0;
  line-height: 1.1;
}

/* Desktop gender label gap fix - high specificity */
.dob-row-fields .dob-field-group:has(#gender) .dob-vertical-label,
.dob-row-fields .dob-field-group .dob-vertical-label[for="gender"],
.dob-row-fields #gender + label,
.dob-row-fields label[for="gender"] {
  margin-right: 3px !important;
}

.dob-row-fields label {
  font-size: 14px;
  font-weight: 600;
  margin: 0 6px 0 0;
  letter-spacing: 1px;
  color: #222;
}
.dob-row-fields > * {
  flex: none !important;
  min-width: 0 !important;
}
.dob-row-fields select,
#dobTypeSelect,
#dob-row select,
#gender,
#lunarHour {
  height: 32px !important;
  font-size: 14px !important;
  margin: 0;
  box-sizing: border-box;
  vertical-align: middle;
  max-width: 110px;
}
#dob-solar-fields,
#dob-lunar-fields {
  display: flex;
  gap: 2px;
  align-items: center;
}
#dob-row {
  width: 100%;
  min-width: 0;
  margin-bottom: 32px !important;
}
#lunarHour {
  max-width: 64px !important;
  width: 64px !important;
  min-width: 0 !important;
}
.dob-row-fields #gregorianMonth,
.dob-row-fields #gregorianDay,
.dob-row-fields #gender {
  max-width: 60px !important;
  width: 60px !important;
  min-width: 0 !important;
}
.dob-row-fields .dob-spacer {
  display: inline-block;
  width: 8px !important;
  min-width: 8px !important;
}
.dob-row-fields > span:not(.dob-spacer) {
  font-size: 14px;
  font-weight: 600;
  color: #222;
  text-align: center;
  line-height: 1.1;
  margin: 0 1px 0 0;
  display: inline-block;
}
/* Remove legacy or conflicting rules for .dob-row-fields, #dob-row, and related selectors */

.row label, .row select, .row > span {
  font-size: 14px;
  font-weight: 600;
  color: #222;
  text-align: center;
  line-height: 1.1;
}

.row + .row {
  margin-top: 16px !important;
}
.row label {
  display: inline-block;
  font-size: 14px;
  font-weight: 600;
  color: #222;
  line-height: 1.1;
  margin: 0 1px 0 0;
  width: auto;
  min-width: 0;
  text-align: left;
}
#interestselect {
  width: 100%;
  max-width: 304px; /* Match other question selectors */
  min-width: 60px;
}

.dob-row-fields #gregorianMonth,
.dob-row-fields #lunarMonth {
  max-width: 75px !important;
  width: 75px !important;
  min-width: 0 !important;
}
.dob-row-fields #gregorianDay,
.dob-row-fields #lunarDay {
  max-width: 60px !important;
  width: 60px !important;
  min-width: 0 !important;
}

.dob-row-fields #gender {
  max-width: 50px !important;
  width: 50px !important;
  min-width: 0 !important;
}
.dob-row-fields #lunarHour {
  max-width: 66px !important;
  width: 66px !important;
  min-width: 0 !important;
}

/* Field groups for desktop - ensure proper alignment */
.dob-field-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* Action buttons on small screens */
.action-btn {
    height: 44px;
    font-size: 14px;
    padding: 8px 12px;
}

.action-btn svg {
    width: 14px;
    height: 14px;
}

/* Download button specific mobile optimizations */
#download-link {
    position: relative;
    overflow: hidden;
}

#download-link:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

#download-link:disabled svg {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Ensure download button is touch-friendly on all mobile devices */
.action-btn.primary {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.3);
}

.action-btn.primary:active {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(0, 123, 255, 0.3);
}

/* Mobile: Group hour and gender on same row when possible */
.dob-field-group:has(#lunarHour) + .dob-field-group:has(#gender) {
    display: flex;
    flex-direction: row;
    gap: 12px;
    align-items: center;
}

/* Alternative approach for browsers that don't support :has() */
.dob-field-group.hour-gender-group {
    display: flex;
    flex-direction: row;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

/* Force override for gender label gap - highest specificity */
body .dob-row-fields .dob-field-group:has(#gender) .dob-vertical-label,
body .dob-row-fields .dob-field-group .dob-vertical-label[for="gender"],
body .dob-row-fields #gender + label,
body .dob-row-fields label[for="gender"] {
  margin-right: 3px !important;
}

/* Additional desktop override for any conflicting rules */
.dob-row-fields .dob-field-group:has(#gender) .dob-vertical-label,
.dob-row-fields .dob-field-group .dob-vertical-label[for="gender"] {
  margin-right: 3px !important;
}

/* Most aggressive desktop override - target the gender label directly */
@media (min-width: 769px) {
  /* Target by ID */
  #gender + label,
  label[for="gender"] {
    margin-right: 3px !important;
  }
  
  /* Target by class and attribute */
  .dob-vertical-label[for="gender"] {
    margin-right: 3px !important;
  }
  
  /* Target by parent container */
  .dob-field-group:has(#gender) .dob-vertical-label {
    margin-right: 3px !important;
  }
}

/* Mobile layout fixes - highest priority */
@media (max-width: 768px) {
  /* Force solar/lunar selector to be inline with date fields */
  .dob-row-fields .dob-field-group:has(#dobTypeSelect) {
    display: block !important;
  }
  
  .dob-row-fields .dob-field-group:has(#dobTypeSelect) #dobTypeSelect {
    display: inline-block !important;
    height: 44px !important;
    font-size: 16px !important;
    margin-right: 8px !important;
  }
  
  /* Force date fields to be inline with solar/lunar selector */
  .dob-row-fields #dob-solar-fields,
  .dob-row-fields #dob-lunar-fields {
    display: inline-flex !important;
  }
  
  /* Hide lunar fields by default on mobile */
  #dob-lunar-fields {
    display: none !important;
  }
  
  /* Show lunar fields only when lunar is selected */
  .dob-row-fields[data-dob-type="lunar"] #dob-lunar-fields {
    display: inline-flex !important;
  }
  
  /* Hide solar fields when lunar is selected */
  .dob-row-fields[data-dob-type="lunar"] #dob-solar-fields {
    display: none !important;
  }
  
  /* Hide lunar fields when solar is selected (explicit rule) */
  .dob-row-fields[data-dob-type="solar"] #dob-lunar-fields {
    display: none !important;
  }
  
  /* Show solar fields when solar is selected (explicit rule) */
  .dob-row-fields[data-dob-type="solar"] #dob-solar-fields {
    display: inline-flex !important;
  }
  
  /* Mobile labels in one line */
  .dob-vertical-label {
    white-space: nowrap !important;
    writing-mode: horizontal-tb !important;
    text-orientation: mixed !important;
    width: auto !important;
    min-width: auto !important;
    height: auto !important;
    line-height: normal !important;
    display: inline-block !important;
  }
  
  /* Hide <br> tags in mobile labels to force single line */
  .dob-vertical-label br {
    display: none !important;
  }
}

/* Unified DOB and form layout for both desktop and mobile */
.dob-section {
  margin-bottom: 24px;
}
.dob-label {
  display: block;
  font-weight: bold;
  font-size: 16px;
  margin-bottom: 6px;
  letter-spacing: 1px;
}
.dob-row-fields.unified-dob-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.dob-date-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
}
#dobTypeSelect,
#gregorianYear, #gregorianMonth, #gregorianDay,
#lunarYear, #lunarMonth, #lunarDay {
  height: 44px;
  font-size: 16px;
  min-width: 60px;
  max-width: 100px;
  margin: 0;
}
#dobTypeSelect {
  min-width: 80px;
  max-width: 120px;
}
#dobTypeSelect {
  margin-right: 8px;
}
#dob-solar-fields, #dob-lunar-fields {
  display: flex;
  flex-direction: row;
  gap: 4px;
  align-items: center;
}
.dob-hour-gender-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  width: 100%;
}
#gender {
  margin-left: 0 !important;
  height: 44px;
  font-size: 16px;
  min-width: 60px;
  max-width: 100px;
  display: block;
}
.zodiac-symbol {
  display: inline-flex !important;
  align-items: center !important;
  vertical-align: middle !important;
  font-size: 1.5em !important;
  min-width: 0; /* allow tight spacing */
  margin-right: 0px !important; /* no gap between icon and text */
  margin-left: 0px !important;
  font-weight: bold;
  cursor: pointer; /* Change from help to pointer for better UX */
  position: relative; /* For tooltip positioning */
}
.zodiac-name {
  display: inline-flex;
  align-items: center;
  margin-left: -1px !important;
  font-size: 16px !important; /* match .dob-label font size */
  font-weight: bold; /* match label weight */
  line-height: 16px;
  position: relative;
  top: 4px; /* nudge down to align with label baseline */
}
.zodiac-symbol:hover::after {
  content: attr(data-zodiac);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 1000;
  margin-bottom: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  pointer-events: none; /* Prevent tooltip from interfering with hover */
}
.form-group {
  margin-bottom: 8px; /* Reduced from 12px to make form more compact */
}
.question-label {
  display: block;
  font-weight: bold;
  font-size: 14px;
  margin-bottom: 3px; /* Reduced from 4px to make form more compact */
}
.form-group select {
  width: 100%;
  height: 44px;
  font-size: 14px; /* Reduced from 16px to match question label size */
  padding: 8px;
  box-sizing: border-box;
  max-width: 304px; /* Make selector width flush with y-m-d row (76px + 228px) */
}
@media (max-width: 768px) {
  .dob-row-fields.unified-dob-row {
    gap: 10px;
  }
  .dob-date-row, .dob-hour-gender-row {
    flex-direction: row;
    gap: 6px;
  }
  .form-group select {
    width: 100%;
  }
  .dob-hour-gender-row {
    gap: 12px;
    width: 100%;
  }
  #gender {
    margin-left: auto !important;
    display: block;
  }
}

/* DOB and form alignment tweaks */
.dob-section, .dob-row-fields.unified-dob-row, .dob-date-row, .dob-hour-gender-row {
  margin-left: 0 !important;
  align-items: flex-start !important;
}
#dobTypeSelect {
  width: 70px !important;
  min-width: 60px !important;
  max-width: 80px !important;
  margin-right: 6px !important;
}
.dob-date-row > #dob-solar-fields,
.dob-date-row > #dob-lunar-fields {
  margin-left: 0 !important;
}
.dob-date-row select {
  margin-right: 6px !important;
}
.dob-hour-gender-row select#lunarHour {
  margin-right: 16px !important;
}
.dob-hour-gender-row label[for="gender"] {
  margin-left: 0 !important;
}
.dob-section, .form-group {
  margin-left: 0 !important;
}

#dob-lunar-fields {
  display: none; /* Hide lunar fields by default */
}

/* Desktop: Hide lunar fields by default, show based on selection */
@media (min-width: 769px) {
  #dob-lunar-fields {
    display: none; /* Hide lunar fields by default on desktop */
  }
  
  /* Show lunar fields when lunar is selected */
  .dob-row-fields[data-dob-type="lunar"] #dob-lunar-fields {
    display: flex !important;
  }
  
  /* Hide solar fields when lunar is selected */
  .dob-row-fields[data-dob-type="lunar"] #dob-solar-fields {
    display: none !important;
  }
}

/* Mobile layout fixes - highest priority */
@media (max-width: 768px) {
  /* Force solar/lunar selector to be inline with date fields */
  .dob-row-fields .dob-field-group:has(#dobTypeSelect) {
    display: block !important;
  }
  
  .dob-row-fields .dob-field-group:has(#dobTypeSelect) #dobTypeSelect {
    display: inline-block !important;
    height: 44px !important;
    font-size: 16px !important;
    margin-right: 8px !important;
  }
  
  /* Force date fields to be inline with solar/lunar selector */
  .dob-row-fields #dob-solar-fields,
  .dob-row-fields #dob-lunar-fields {
    display: inline-flex !important;
  }
  
  /* Hide lunar fields by default on mobile */
  #dob-lunar-fields {
    display: none !important;
  }
  
  /* Show lunar fields only when lunar is selected */
  .dob-row-fields[data-dob-type="lunar"] #dob-lunar-fields {
    display: inline-flex !important;
  }
  
  /* Hide solar fields when lunar is selected */
  .dob-row-fields[data-dob-type="lunar"] #dob-solar-fields {
    display: none !important;
  }
  
  /* Hide lunar fields when solar is selected (explicit rule) */
  .dob-row-fields[data-dob-type="solar"] #dob-lunar-fields {
    display: none !important;
  }
  
  /* Show solar fields when solar is selected (explicit rule) */
  .dob-row-fields[data-dob-type="solar"] #dob-solar-fields {
    display: inline-flex !important;
  }
  
  /* Mobile labels in one line */
  .dob-vertical-label {
    white-space: nowrap !important;
    writing-mode: horizontal-tb !important;
    text-orientation: mixed !important;
    width: auto !important;
    min-width: auto !important;
    height: auto !important;
    line-height: normal !important;
    display: inline-block !important;
  }
  
  /* Hide <br> tags in mobile labels to force single line */
  .dob-vertical-label br {
    display: none !important;
  }
}