/* General Body & Root Styles */
:root {
    /* Color Palette */
    --primary-color: #0A0A23;
    --primary-light: #2A2A4A;
    --secondary-color: #FFD700;
    --accent-color-1: #FF6B6B;
    --accent-color-2: #00BFFF;
    --sun-color: #FFD700;
    --moon-color: #00BFFF;
    --success-color: var(--secondary-color);
    --error-color: var(--accent-color-1);
    --error-bg-light: #FFEDED;
    --background-body-start: #1A1A2E;
    --background-body-end: #0F0F1A;
    --background-section: #1E1E3C;
    --background-grid-cell: #2F2F5E;
    --background-grid-cell-empty: #27274E;
    --text-dark: #F0F0F0;
    --text-light: #FFFFFF;
    --text-accent: var(--secondary-color);
    --border-dark: #4A4A8A;
    --border-light: #6A6ABD;
    --border-error: var(--error-color);
    --grid-solved-bg: #2F2F5E;
    --grid-solved-border: var(--success-color);

    /* Typography & Spacing */
    --grid-cell-width: 80px;
    --font-family: 'Poppins', Arial, sans-serif;
    --heading-font-weight: 800;
    --body-font-weight: 400;
    --line-height-body: 1.8;
    --spacing-xs: 5px;
    --spacing-sm: 10px;
    --spacing-md: 15px;
    --spacing-lg: 25px;
    --spacing-xl: 40px;
}

body {
    font-family: var(--font-family);
    line-height: var(--line-height-body);
    margin: 0;
    background: linear-gradient(135deg, var(--background-body-start) 0%, var(--background-body-end) 100%);
    color: var(--text-dark);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-size: 16px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-lg);
    box-sizing: border-box;
}

/* --- COMPACT HEADER --- */
.site-header {
    background: linear-gradient(90deg, var(--primary-light) 0%, var(--accent-color-2) 100%);
    color: var(--text-light);
    padding: 8px 0; /* A little padding for vertical centering */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    position: relative;
    border-bottom: 2px solid var(--secondary-color);
}

/* NEW: Use Flexbox to align header items */
.site-header .container {
    display: flex;
    justify-content: center;
    align-items: baseline; /* Aligns the bottom of the text */
    gap: 1em;
    flex-wrap: wrap; /* Allows wrapping on very small screens */
    padding-top: 0;
    padding-bottom: 0;
}

.site-header h1 {
    margin: 0;
    font-size: 1.4em; /* Slightly larger for emphasis */
    font-weight: var(--heading-font-weight);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    line-height: 1; /* Tighter line height */
}

.header-link {
    text-decoration: none;
    color: inherit;
    transition: opacity 0.2s ease-in-out;
}
.header-link:hover {
    opacity: 0.9;
}

.site-header .tagline {
    font-size: 0.8em; /* Adjusted for balance */
    margin: 0; /* Removed top margin */
    opacity: 0.8;
    line-height: 1; /* Tighter line height */
    padding-bottom: 2px; /* Small padding to help with baseline alignment */
}

.main-content {
    flex-grow: 1;
    padding-top: var(--spacing-xl);
    padding-bottom: var(--spacing-xl);
}

section {
    background-color: var(--background-section);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255,255,255,0.1);
}

section h2 {
    color: var(--secondary-color);
    font-size: 2.5em;
    font-weight: var(--heading-font-weight);
    margin-top: 0;
    margin-bottom: var(--spacing-lg);
    text-align: center;
    position: relative;
    padding-bottom: var(--spacing-sm);
}

section h2::after {
    content: '';
    display: block;
    width: 80px;
    height: 6px;
    background-color: var(--accent-color-1);
    margin: var(--spacing-sm) auto 0;
    border-radius: 3px;
}

/* --- MODIFIED GAME HEADING --- */
#game-heading {
    font-size: 1.8em; /* Reduced font size */
    margin-bottom: var(--spacing-md); /* Reduced margin */
    padding-bottom: 0;
    font-weight: 600; /* Made slightly less bold */
    color: var(--text-dark); /* Changed color to be less prominent */
}

#game-heading::after {
    display: none; /* Removed the underline */
}


/* Text alignment */
.intro-section p,
.about-section p,
.how-to-play-section ol > li {
    text-align: left;
}

.intro-section .play-cta {
    font-size: 1.4em;
    font-weight: bold;
    color: var(--secondary-color);
    text-align: center;
    margin-top: var(--spacing-lg);
    animation: pulse 2s infinite ease-in-out;
    text-shadow: 0 0 10px rgba(255,215,0,0.5);
}

/* Game Section */
.game-section {
    text-align: center;
}

#game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-lg); /* This is the 25px space between grid and controls */
    margin-top: var(--spacing-lg);
}

.grid-6x6 {
    display: grid;
    grid-template-columns: repeat(6, var(--grid-cell-width));
    grid-template-rows: repeat(6, var(--grid-cell-width));
    border: 3px solid var(--border-dark);
    gap: 1px;
    background-color: var(--border-dark);
    width: fit-content;
    margin: 0 auto;
    position: relative;
    box-shadow: 0 0 30px rgba(0,0,0,0.6);
    border-radius: 10px;
    overflow: hidden;
}

.grid-cell {
    width: var(--grid-cell-width);
    height: var(--grid-cell-width);
    background-color: var(--background-grid-cell-empty);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.8em;
    cursor: pointer;
    border: 1px solid var(--border-light);
    transition: background-color 0.2s ease-in-out, transform 0.1s ease-out;
    user-select: none;
    position: relative;
    color: var(--text-light);
}

.grid-cell:hover {
    background-color: var(--background-grid-cell);
}

.grid-cell.sun-symbol {
    color: var(--sun-color);
    background-color: var(--background-grid-cell);
    text-shadow: 0 0 15px var(--sun-color);
}

.grid-cell.moon-symbol {
    color: var(--moon-color);
    background-color: var(--background-grid-cell);
    text-shadow: 0 0 15px var(--moon-color);
}

.grid-cell.fixed-cell {
    background-color: var(--primary-light);
    cursor: default;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.4);
    border-color: var(--primary-color);
}
.grid-cell.fixed-cell:hover {
    transform: none;
}

/* Constraint Indicators */
.constraint {
    position: absolute;
    font-size: 0.65em;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-light);
    font-weight: bold;
    z-index: 20;
    pointer-events: none;
    box-shadow: 0 1px 4px rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.3);
}
.constraint-equal { background-color: var(--primary-light); }
.constraint-cross { background-color: var(--error-color); }

/* Game Controls & Feedback */
#game-controls {
    display: flex;
    gap: var(--spacing-md);
    flex-wrap: wrap;
    justify-content: center;
}

.btn {
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.05em;
    font-weight: var(--heading-font-weight);
    transition: all 0.2s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.btn:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.btn-primary {
    background-color: var(--accent-color-1);
    color: var(--text-light);
}

.btn-primary:hover {
    background-color: #CC5555;
}

.btn-secondary {
    background-color: var(--primary-light);
    color: var(--text-light);
}

.btn-secondary:hover {
    background-color: #3C3C7C;
}

/* --- MODIFIED: Feedback Area Layout --- */
.feedback-area {
    margin-top: 0; /* Margin is now handled by the elements inside */
    min-height: 100px; /* Reduced min-height */
    display: flex;
    flex-direction: column;
    align-items: center;
}

#message {
    font-size: 1.25em;
    font-weight: bold;
    text-align: center;
    order: 2; /* Appear after timer */
    margin-top: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.info-message { color: var(--accent-color-2); }
.success-message { color: var(--secondary-color); }
.warning-message { color: var(--warning-color); }
.error-message { color: var(--error-color); }

.error-list {
    list-style: none;
    padding: 0;
    color: var(--error-color);
    text-align: left;
    margin: 0 auto; /* Removed top/bottom margin */
    max-width: 600px;
    order: 3; /* Appear last */
}

.error-list li {
    margin-bottom: var(--spacing-xs);
    background-color: rgba(255, 107, 107, 0.1);
    border-left: 8px solid var(--border-error);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 8px;
    animation: fadeIn 0.4s ease-out;
}

/* --- MODIFIED: Timer Position --- */
.timer-display {
    font-size: 1.5em;
    font-weight: bold;
    color: var(--secondary-color);
    margin-top: var(--spacing-lg); /* NEW: This creates the 25px gap */
    text-align: center;
    background-color: rgba(255,255,255,0.1);
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: 10px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.3);
    order: 1; /* Appear first in the feedback area */
}

/* How to Play Section */
.rules-list ol { list-style: none; counter-reset: list-item; padding-left: 0; }
.rules-list ol > li { counter-increment: list-item; margin-bottom: var(--spacing-md); position: relative; padding-left: var(--spacing-lg); }
.rules-list ol > li::before { content: counter(list-item) "."; position: absolute; left: 0; top: 0; font-weight: var(--heading-font-weight); color: var(--secondary-color); font-size: 1.2em; line-height: var(--line-height-body); }
.rules-list ul { list-style-type: disc !important; margin-top: var(--spacing-sm); padding-left: var(--spacing-xl); }
.rules-list ul li { padding-left: var(--spacing-xs); margin-bottom: var(--spacing-xs); position: static; }
.rules-list ul li::before { all: unset !important; }
.rules-list .constraint-equal, .rules-list .constraint-cross { display: inline-block; width: 18px; height: 18px; line-height: 18px; text-align: center; border-radius: 50%; color: var(--text-light); font-weight: bold; font-size: 0.85em; vertical-align: middle; margin: 0 2px; }

/* --- COMPACT FOOTER --- */
.site-footer {
    background-color: var(--background-section);
    color: var(--text-light);
    text-align: center;
    padding: 10px 0;
    font-size: 0.8em;
    margin-top: auto;
    border-top: 2px solid var(--primary-light);
}

.site-footer p {
    margin: var(--spacing-xs) 0;
    opacity: 0.8;
}

.footer-links {
    margin-bottom: var(--spacing-sm);
    display: flex;
    justify-content: center;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}
.footer-links a {
    color: var(--text-dark);
    text-decoration: none;
    transition: color 0.2s ease-in-out;
}
.footer-links a:hover {
    color: var(--secondary-color);
}


/* Animations */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

.shake {
    animation: shake 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.grid-cell.error-cell {
    border-color: var(--border-error) !important;
    animation: pulseBorder 0.8s infinite alternate !important;
}

@keyframes pulseBorder {
    from { box-shadow: inset 0 0 10px var(--border-error); }
    to { box-shadow: inset 0 0 15px var(--border-error); }
}

.grid-cell.solved-cell {
    background-color: var(--grid-solved-bg) !important;
    border-color: var(--grid-solved-border) !important;
    animation: fadeIn 0.5s ease-out;
}

/* Responsive Design */
@media (max-width: 992px) {
    section h2 { font-size: 2em; }
    .grid-6x6 { grid-template-columns: repeat(6, 70px); grid-template-rows: repeat(6, 70px); }
    .grid-cell { --grid-cell-width: 70px; font-size: 2.6em; }
}

@media (max-width: 768px) {
    .container { padding: var(--spacing-md); }
    .site-header h1 { font-size: 1.6em; }
    section { padding: var(--spacing-lg); }
    section h2 { font-size: 1.8em; }
    .intro-section p, .about-section p { font-size: 0.95em; }
    .grid-6x6 { grid-template-columns: repeat(6, 60px); grid-template-rows: repeat(6, 60px); }
    .grid-cell { --grid-cell-width: 60px; font-size: 2.3em; }
    #game-controls { flex-direction: column; }
}

@media (max-width: 480px) {
    .site-header h1 { font-size: 1.4em; }
    section { padding: var(--spacing-md); }
    section h2 { font-size: 1.6em; }
    .grid-6x6 { grid-template-columns: repeat(6, 48px); grid-template-rows: repeat(6, 48px); }
    .grid-cell { --grid-cell-width: 48px; font-size: 1.9em; }
    .btn { width: 100%; margin-bottom: var(--spacing-sm); }
