/* General Body & Root Styles */
:root {
    /* Completely new palette */
    --primary-color: #0b1020;
    --primary-light: #172033;
    --secondary-color: #8b5cf6;
    --accent-color-1: #22d3ee;
    --accent-color-2: #f472b6;
    --sun-color: #f472b6;
    --moon-color: #67e8f9;
    --success-color: #4ade80;
    --error-color: #fb7185;
    --warning-color: #f59e0b;
    --error-bg-light: #2a1620;
    --background-body-start: #060816;
    --background-body-end: #111827;
    --background-section: #181f32;
    --background-grid-cell: #22304a;
    --background-grid-cell-empty: #172236;
    --text-dark: #eef2ff;
    --text-light: #ffffff;
    --text-accent: #c4b5fd;
    --border-dark: #2d3b57;
    --border-light: #3b4b69;
    --border-error: #fb7185;
    --grid-solved-bg: #16362a;
    --grid-solved-border: #4ade80;

    /* Typography & Spacing */
    --grid-cell-width: 60px;
    --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;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    position: relative;
    border-bottom: 2px solid var(--secondary-color);
}

.site-header .container {
    display: flex;
    justify-content: center;
    align-items: baseline;
    gap: 1em;
    flex-wrap: wrap;
    padding-top: 0;
    padding-bottom: 0;
}

.site-header h1 {
    margin: 0;
    font-size: 1.4em;
    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;
}

.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;
    margin: 0;
    opacity: 0.8;
    line-height: 1;
    padding-bottom: 2px;
}

.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;
}

.seo-content-section {
    background: linear-gradient(145deg, rgba(17, 24, 39, 0.96) 0%, rgba(23, 32, 51, 0.98) 100%);
    border: 1px solid rgba(139, 92, 246, 0.22);
    box-shadow: 0 18px 40px rgba(6, 8, 22, 0.35);
}

.section-intro {
    text-align: center;
    max-width: 860px;
    margin: 0 auto 1.5rem;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.25em;
    font-size: 0.82rem;
    color: #a78bfa;
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.section-lead {
    color: #e5eefb;
    font-size: 1.02rem;
}

.content-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.full-width-card {
    margin-top: 18px;
}

.disclaimer-card {
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.98) 0%, rgba(15, 23, 42, 0.98) 100%);
    border-color: rgba(244, 114, 182, 0.22);
}

.content-card {
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.96) 0%, rgba(17, 24, 39, 0.98) 100%);
    border: 1px solid rgba(139, 92, 246, 0.18);
    border-radius: 16px;
    padding: 18px;
    box-shadow: 0 12px 28px rgba(6, 8, 22, 0.28);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.content-card:hover {
    transform: translateY(-3px);
    border-color: rgba(56, 189, 248, 0.45);
}

.content-chip {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: #67e8f9;
    margin-bottom: 0.45rem;
}

.content-card h3 {
    color: #ede9fe;
    font-size: 1.08rem;
    margin: 0 0 0.45rem;
}

.content-card p {
    color: #e5eefb;
    margin: 0;
    font-size: 0.98rem;
}

/* --- MODIFIED GAME HEADING --- */
#game-heading {
    font-size: 1.65em;
    margin: 0 0 0.35rem 0;
    padding-bottom: 0;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-dark);
}

#game-heading::after {
    display: none;
}

/* 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;
    margin-top: 0;
    padding-top: 0.4rem;
    padding-bottom: 0.8rem;
}

#game-container {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    gap: 1.2rem;
    margin-top: 0.25rem;
}



.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);
    border: 1px solid #8b5cf6;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.8em;
    cursor: pointer;
    border: 1px solid #8b5cf6;
    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:focus-visible {
    outline: 2px solid var(--secondary-color);
    outline-offset: -2px;
}

.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 - FIXED FOR MOBILE */
.constraint {
    position: absolute;
    /* Size and font-size are now set by JavaScript for responsiveness */
    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);
    transition: width 0.2s ease, height 0.2s ease, font-size 0.2s ease;
}

.constraint-equal { 
    background-color: var(--primary-light); 
}

.constraint-cross { 
    background-color: var(--error-color); 
}

/* Game Controls & Feedback */
#game-controls {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    justify-content: flex-start;
    align-items: stretch;
    width: 280px;
}

#timer-display {
    margin-top: 0;
}

#new-puzzle-button {
    order: 1;
}

.btn {
    padding: 8px 12px;
    border: 1px solid #ffffff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    width: 100%;
    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:focus-visible {
    outline: 3px solid var(--secondary-color);
    outline-offset: 2px;
}

.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;
    min-height: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 280px;
}

#message {
    font-size: 1.05em;
    font-weight: bold;
    text-align: left;
    order: 2;
    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;
    max-width: 600px;
    order: 3;
}

.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.05em;
    font-weight: 700;
    color: var(--secondary-color);
    margin-top: 0;
    text-align: center;
    background-color: rgba(255,255,255,0.12);
    padding: 0.35rem 0.55rem;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    box-shadow: inset 0 0 8px rgba(0,0,0,0.25);
    width: 100%;
    box-sizing: border-box;
}

.check-popup {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1200;
}

.check-popup.show {
    display: flex;
}

.check-popup-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(7, 10, 20, 0.72);
}

.check-popup-card {
    position: relative;
    width: min(92vw, 420px);
    max-height: 90vh;
    overflow-y: auto;
    background: linear-gradient(180deg, #1f2340 0%, #15172b 100%);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
    padding: 1rem 1rem 1.1rem;
    color: #fff;
}

.check-popup-close {
    position: absolute;
    top: 0.45rem;
    right: 0.55rem;
    border: none;
    background: transparent;
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
}

.check-popup-card h3 {
    margin: 0 0 0.35rem;
    color: #ffd54a;
    font-size: 1.1rem;
}

.check-popup-card p {
    margin: 0 0 0.6rem;
    color: #eef4ff;
    line-height: 1.4;
}

.check-popup-errors {
    margin: 0;
    padding-left: 1rem;
    color: #ffb3b3;
}

.check-popup-errors li + li {
    margin-top: 0.35rem;
}

/* 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: linear-gradient(135deg, #111827 0%, #172033 50%, #0b1020 100%);
    color: var(--text-light);
    text-align: center;
    padding: 14px 0 12px;
    font-size: 0.88em;
    margin-top: auto;
    border-top: 1px solid rgba(192, 132, 252, 0.18);
    box-shadow: 0 -6px 18px rgba(6, 8, 22, 0.35);
}

.site-footer p {
    margin: 0.25rem 0;
    opacity: 0.9;
    color: #e5eefb;
}

.footer-links {
    margin-bottom: var(--spacing-sm);
    display: flex;
    justify-content: center;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

.footer-links a {
    color: #e5eefb;
    text-decoration: none;
    transition: color 0.2s ease-in-out, transform 0.2s ease-in-out;
}

.footer-links a:hover {
    color: #c4b5fd;
    transform: translateY(-1px);
}

/* 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);
    animation: pulseBorder 0.8s infinite alternate;
}

@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);
    border-color: var(--grid-solved-border);
    animation: fadeIn 0.5s ease-out;
}

/* Accessibility: Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Responsive Design */
@media (max-width: 992px) {
    :root {
        --grid-cell-width: 56px;
    }
    section h2 { font-size: 2em; }
    .grid-cell { font-size: 2.2em; }
}

@media (max-width: 980px) {
    #game-container {
        flex-direction: column;
        align-items: center;
    }

    #game-controls,
    .feedback-area {
        width: 100%;
        justify-content: center;
        align-items: center;
        text-align: center;
    }

    #message,
    .timer-display {
        text-align: center;
    }
}

@media (max-width: 768px) {
    :root {
        --grid-cell-width: 50px;
    }
    .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-cell { font-size: 2.0em; }
    #game-controls { flex-direction: column; }
}

@media (max-width: 480px) {
    :root {
        --grid-cell-width: 44px;
    }
    .site-header h1 { font-size: 1.4em; }
    section { padding: var(--spacing-md); }
    section h2 { font-size: 1.6em; }
    .grid-cell { font-size: 1.7em; }
    .btn { 
        width: 100%; 
        margin-bottom: var(--spacing-sm); 
        min-height: 44px;
    }
}

/* Hover states for touch devices */
@media (hover: none) {
    .grid-cell:hover {
        background-color: var(--background-grid-cell-empty);
    }
}