/* --- Base & Reset --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Lato', sans-serif;
    line-height: 1.6;
    background-color: #f8f9fa; /* Light grey background */
    color: #343a40; /* Dark grey text */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 0 1rem; /* Add padding for smaller screens */
}

main {
    flex: 1;
    max-width: 900px;
    margin: 2rem auto; /* Center content */
    width: 100%;
}

/* --- Typography --- */
h1, h2, h3 {
    font-family: 'Merriweather', serif;
    color: #1a3a5a; /* Deep blue heading */
    margin-bottom: 0.8em;
    line-height: 1.3;
}

h1 {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 0.2em;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

header p {
    text-align: center;
    color: #495057;
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

h2 {
    font-size: 1.8rem;
    border-bottom: 2px solid #dee2e6; /* Light separator */
    padding-bottom: 0.3em;
    margin-top: 2rem;
}

h3 {
    font-size: 1.4rem;
    color: #2a527a; /* Slightly lighter blue */
}

p, li, label, span, button, input, summary {
    font-size: 1rem;
}

a {
    color: #007bff;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

strong {
    font-weight: 700;
    color: #1a3a5a;
}

/* --- Layout & Sections --- */
section {
    background-color: #ffffff; /* White background for sections */
    padding: 1.5rem 2rem;
    margin-bottom: 2rem;
    border-radius: 8px; /* Subtle rounded corners */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); /* Subtle "3D" shadow */
    border: 1px solid #e9ecef; /* Light border */
}

/* --- Form Elements --- */
#dob-form {
    display: flex;
    flex-wrap: wrap; /* Allow wrapping on small screens */
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

label {
    font-weight: bold;
    color: #495057;
    margin-right: 0.5rem;
}

input[type="date"] {
    padding: 0.75rem 1rem;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
    flex-grow: 1; /* Take available space */
    min-width: 180px; /* Ensure minimum width */
    background-color: #fff;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.06);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="date"]:focus {
    outline: none;
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Style date input placeholder text */
input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.8;
}
input[type="date"]::-webkit-datetime-edit {
    /* Basic styling to ensure consistency */
    color: #495057;
}


.cta-button, .secondary-button {
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    font-weight: bold;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.1s ease, box-shadow 0.3s ease;
    text-align: center;
}

.cta-button {
    background-color: #007bff; /* Primary blue */
    color: white;
    box-shadow: 0 2px 5px rgba(0, 123, 255, 0.3);
}

.cta-button:hover {
    background-color: #0056b3; /* Darker blue */
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.4);
}

.cta-button:active {
    transform: translateY(1px);
    box-shadow: 0 1px 3px rgba(0, 123, 255, 0.3);
}

.secondary-button {
    background-color: #6c757d; /* Grey */
    color: white;
     box-shadow: 0 2px 5px rgba(108, 117, 125, 0.3);
     margin-top: 1.5rem;
}

.secondary-button:hover {
    background-color: #5a6268;
    box-shadow: 0 4px 8px rgba(108, 117, 125, 0.4);
}
.secondary-button:active {
     transform: translateY(1px);
     box-shadow: 0 1px 3px rgba(108, 117, 125, 0.3);
}


/* --- Results Section --- */
.results-container {
    display: grid;
    grid-template-columns: 1fr; /* Default: single column */
    gap: 2rem;
    margin-top: 1.5rem;
}

/* Grid and Key Numbers side-by-side on larger screens */
@media (min-width: 650px) {
    .results-container {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); /* Responsive columns */
    }
    .grid-and-numbers {
       display: flex;
       flex-direction: column; /* Stack grid above key numbers */
       align-items: center; /* Center grid */
       gap: 1.5rem;
    }
}
@media (min-width: 900px) {
     .grid-and-numbers {
        flex-direction: row; /* Place grid and key numbers side by side */
        align-items: flex-start; /* Align top */
        gap: 2rem;
    }
     #grid-container {
        flex-shrink: 0; /* Prevent grid from shrinking */
    }
}

/* --- Lo Shu Grid --- */
#grid-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    width: 200px; /* Fixed size for consistency */
    height: 200px;
    margin: 0 auto 1.5rem auto; /* Center grid */
    padding: 10px;
    background: linear-gradient(145deg, #e6e9ed, #ffffff); /* Subtle gradient */
    border-radius: 8px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.05), 0 2px 5px rgba(0,0,0,0.1);
}

.grid-cell {
    background-color: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1; /* Maintain square shape */
    position: relative;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.grid-cell .base-digit {
    position: absolute;
    top: 5px;
    left: 5px;
    font-size: 0.75rem;
    color: #adb5bd; /* Light grey for base digit */
}

.grid-cell .count {
    font-size: 1.8rem;
    font-weight: bold;
    color: #1a3a5a; /* Deep blue for count */
    opacity: 0; /* Initially hidden */
    transition: opacity 0.5s ease;
}

.grid-cell .count.visible {
    opacity: 1;
}

/* --- Key Numbers & Planes --- */
#key-numbers, #planes-analysis {
    padding: 1rem;
    background-color: #f8f9fa; /* Slightly different background */
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

#key-numbers p, #planes-analysis p, #planes-analysis li {
    margin-bottom: 0.6rem;
}

#planes-analysis ul {
    list-style: none;
    padding-left: 0;
    margin-top: 1rem;
}

#planes-analysis li {
    padding: 0.4rem 0;
    border-bottom: 1px dashed #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
#planes-analysis li:last-child {
    border-bottom: none;
}

.plane-name {
    color: #343a40;
}
.plane-numbers {
    font-size: 0.9rem;
    color: #6c757d;
    margin-left: 0.5rem;
}
.plane-status {
    font-weight: bold;
    font-size: 1.2rem;
}
.active-symbol {
    color: #28a745; /* Green for active */
}
.inactive-symbol {
    color: #dc3545; /* Red for inactive */
}
.plane-note {
    font-size: 0.9em;
    color: #6c757d;
    margin-top: 1rem;
}

/* --- Instructions & FAQ --- */
#instructions ol {
    padding-left: 1.5rem;
    margin-top: 1rem;
}

#instructions li {
    margin-bottom: 0.5rem;
}

#faq details {
    margin-bottom: 1rem;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 0.8rem 1.2rem;
    transition: background-color 0.3s ease;
}

#faq summary {
    font-weight: bold;
    cursor: pointer;
    color: #2a527a;
    list-style: none; /* Remove default marker */
    position: relative;
    padding-right: 1.5em; /* Space for custom marker */
}

#faq summary::-webkit-details-marker {
    display: none; /* Hide default marker (Chrome/Safari) */
}

#faq summary::after { /* Custom marker */
    content: '+';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.4em;
    color: #007bff;
    transition: transform 0.2s ease;
}

#faq details[open] summary::after {
    content: '−'; /* Minus sign when open */
    transform: translateY(-50%);
}


#faq details[open] {
     background-color: #eef2f7; /* Slightly different background when open */
}

#faq p, #faq ul, #faq pre {
    margin-top: 0.8rem;
    padding-left: 0.5rem;
    color: #495057;
}
#faq ul {
    padding-left: 1.5rem;
}
#faq pre {
    background-color: #e9ecef;
    padding: 0.5rem;
    border-radius: 4px;
    font-family: monospace;
    white-space: pre-wrap;
    word-wrap: break-word;
}


/* --- Utility Classes --- */
.hidden {
    display: none !important; /* Use important to override potential conflicts */
}

.error {
    color: #dc3545; /* Red for errors */
    font-weight: bold;
    margin-top: 0.5rem;
}

/* --- Footer --- */
footer {
    text-align: center;
    margin-top: 2rem;
    padding: 1rem 0;
    font-size: 0.9rem;
    color: #6c757d;
    border-top: 1px solid #dee2e6;
}

/* --- Accessibility --- */
*:focus-visible { /* Modern focus indicator for keyboard users */
  outline: 2px solid #0056b3;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.3);
  border-radius: 2px; /* Consistent rounding */
}
/* Fallback for older browsers */
*:focus {
    outline: 2px solid #0056b3;
    outline-offset: 2px;
}
/* Remove outline if focus-visible is supported and element does not match it */
*:focus:not(:focus-visible) {
  outline: none;
  box-shadow: none;
}


/* --- Responsive Adjustments --- */
@media (max-width: 768px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.6rem; }
    h3 { font-size: 1.3rem; }
    section { padding: 1rem 1.2rem; }
    #dob-form { flex-direction: column; align-items: stretch; }
    input[type="date"], .cta-button { width: 100%; }

    #grid-container { width: 180px; height: 180px; } /* Slightly smaller grid */
    .grid-cell .count { font-size: 1.6rem; }
}

@media (max-width: 480px) {
    body { padding: 0 0.5rem; }
    main { margin: 1rem auto; }
    h1 { font-size: 1.8rem; }
    h2 { font-size: 1.4rem; }
    h3 { font-size: 1.2rem; }
    section { padding: 1rem; }
    #grid-container { width: 160px; height: 160px; }
    .grid-cell .count { font-size: 1.4rem; }
     #key-numbers p, #planes-analysis li { font-size: 0.95rem; }
    .cta-button, .secondary-button { padding: 0.7rem 1rem; font-size: 0.95rem; }
    #faq summary { font-size: 0.95rem; }
    #faq p, #faq li { font-size: 0.9rem; }
}