:root {
    --primary-color: #2563eb; /* Royal Blue */
    --primary-hover: #1d4ed8;
    --secondary-color: #dc2626; /* Red */
    --bg-color: #f8fafc; /* Very Light Gray/White */
    --text-color: #1e293b; /* Dark Slate */
    --text-muted: #64748b;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --font-heading: 'Orbitron', sans-serif;
    --font-body: 'Roboto', sans-serif;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.3s;
}

a:hover {
    color: var(--primary-color);
}

/* Navbar */
.navbar {
    background-color: #ffffff;
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f172a;
}

.highlight {
    color: var(--primary-color);
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 20px;
}

.nav-links a {
    color: var(--text-color);
    font-weight: 500;
}

.nav-links a:hover {
    color: var(--primary-color);
}

/* Game Area */
.game-header {
    text-align: center;
    padding: 2rem 0;
}

.game-header h1 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    color: #0f172a;
    margin-bottom: 0.5rem;
}

.game-header p {
    color: var(--text-muted);
}

.game-container-wrapper {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 0 20px 40px;
    flex-wrap: wrap;
}

.game-area {
    position: relative;
    width: 100%;
    max-width: 500px;
    background: #ffffff;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Sudoku Styles */
.sudoku-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#sudoku-controls-top {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.difficulty-selector {
    display: flex;
    gap: 0.5rem;
}

.diff-btn {
    background: none;
    border: 1px solid var(--border-color);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: all 0.2s;
}

.diff-btn.active, .diff-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.timer-display {
    font-family: monospace;
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--text-color);
}

#sudoku-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 0;
    border: 2px solid #0f172a;
    width: 100%;
    max-width: 450px;
    aspect-ratio: 1/1;
    background: #fff;
}

.sudoku-cell {
    border: 1px solid #cbd5e1;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.1s;
    position: relative;
}

/* Thicker borders for 3x3 blocks */
.sudoku-cell:nth-child(3n) {
    border-right: 2px solid #0f172a;
}
.sudoku-cell:nth-child(9n) {
    border-right: none; /* Handled by grid border */
}
.sudoku-cell:nth-child(n+19):nth-child(-n+27),
.sudoku-cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 2px solid #0f172a;
}

/* Cell States */
.sudoku-cell.fixed {
    color: #0f172a;
    font-weight: 700;
    background-color: #f8fafc;
}

.sudoku-cell.user-input {
    color: var(--primary-color);
}

.sudoku-cell:hover {
    background-color: #e2e8f0;
}

.sudoku-cell.selected {
    background-color: #bfdbfe; /* Light Blue */
}

.sudoku-cell.highlight-related {
    background-color: #e0f2fe; /* Very Light Blue */
}

.sudoku-cell.highlight-same {
    background-color: #93c5fd; /* Medium Blue */
}

.sudoku-cell.error {
    background-color: #fecaca; /* Light Red */
    color: #dc2626;
}

/* Controls Bottom */
#sudoku-controls-bottom {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.number-pad {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.num-btn, .action-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 8px;
    font-size: 1.2rem;
    color: var(--primary-color);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.num-btn:hover, .action-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

.action-btn {
    color: var(--secondary-color);
}
.action-btn:hover {
    background: var(--secondary-color);
}

.game-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

#btn-new-game, #btn-play-again {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

#btn-new-game:hover, #btn-play-again:hover {
    background: var(--primary-hover);
}

/* Game Over Modal */
#game-over-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    text-align: center;
    border: 1px solid var(--border-color);
}

.modal-content h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.modal-content p {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.hidden {
    display: none !important;
}

/* Game Log Panel */
#game-log-panel {
    width: 100%;
    max-width: 300px;
    height: 600px; 
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
}

#game-log-panel h3 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: #0f172a;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

#log-container {
    flex: 1;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    display: flex;
    flex-direction: column; /* Normal order */
}

.log-entry {
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px dashed #f1f5f9;
}

.log-time {
    color: #94a3b8;
    font-size: 0.8rem;
    margin-right: 5px;
}

.log-msg {
    color: var(--text-color);
}

.log-msg.info { color: #2563eb; }
.log-msg.danger { color: #dc2626; font-weight: bold; }
.log-msg.success { color: #16a34a; }

/* Utilities */
.active { display: block; }
.hidden { display: none !important; }

h2 {
    font-family: var(--font-heading);
    margin-bottom: 1rem;
    color: #0f172a;
}

/* Global Button Styles */
button {
    font-family: var(--font-heading);
}

/* Content Sections */
.content-section {
    padding: 4rem 0;
}

.alt-bg {
    background-color: #ffffff;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.feature-card {
    background: #ffffff;
    padding: 2rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s;
}

.feature-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.feature-card h3 {
    font-family: var(--font-heading);
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.feature-card p {
    color: var(--text-muted);
}

.section-intro {
    text-align: center;
    max-width: 800px;
    margin: 0 auto 2rem;
    font-size: 1.1rem;
    color: var(--text-muted);
}

.game-lore {
    margin-top: 3rem;
    padding: 2rem;
    background: #f1f5f9;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.game-lore h3 {
    font-family: var(--font-heading);
    color: #0f172a;
    margin-bottom: 1rem;
}

.game-lore p {
    margin-bottom: 1rem;
    color: var(--text-muted);
}

/* Footer */
.site-footer {
    background-color: #1e293b; /* Keep footer dark for contrast */
    padding: 3rem 0;
    margin-top: auto;
    color: #cbd5e1;
}

.footer-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.footer-logo {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    color: #fff;
}

.footer-links a {
    margin-left: 20px;
    font-size: 0.9rem;
    color: #94a3b8;
}

.footer-links a:hover {
    color: #fff;
}

.copyright {
    text-align: center;
    color: #64748b;
    font-size: 0.8rem;
    margin-top: 2rem;
}

/* Cookie Banner */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #ffffff;
    padding: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
    z-index: 2000;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 6px -1px rgb(0 0 0 / 0.1);
}

.cookie-banner.show {
    transform: translateY(0);
}

.cookie-banner p {
    font-size: 0.9rem;
    max-width: 600px;
    color: var(--text-color);
}

.cookie-buttons {
    display: flex;
    gap: 10px;
}

.cookie-buttons button {
    padding: 8px 16px;
    font-size: 0.8rem;
}

#decline-cookies {
    background: transparent;
    border: 1px solid var(--text-muted);
    color: var(--text-color);
}

#decline-cookies:hover {
    background: #f1f5f9;
}

/* Mobile */
@media (max-width: 768px) {
    .navbar .container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .game-container-wrapper {
        flex-direction: column;
        align-items: center;
    }
    
    #game-log-panel {
        max-width: 500px;
        height: 200px;
    }

    .footer-content {
        flex-direction: column;
        gap: 1.5rem;
        text-align: center;
    }
    
    .footer-links a {
        margin: 0 10px;
    }
    
    .cookie-banner {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
}