:root {
    --primary-color: #4a6fa5;
    --visited-color: #e0e0e0;
    --valid-move-color: #a5d6a7;
    --text-color: #333;
    --background-color: #f5f5f5;
    --cell-border: 1px solid #999;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-color);
    padding: 20px;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

.game-container {
    max-width: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

h1 {
    text-align: center;
    margin-bottom: 10px;
    color: var(--primary-color);
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-end;
    justify-content: center;
    margin-bottom: 20px;
    width: 100%;
    background: rgba(255, 255, 255, 0.9);
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

/* Control group for board size - label on left */
.control-group:has(#board-size) {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    min-width: auto;
    margin-bottom: 0;
}

/* Default control group style */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 180px;
    margin-bottom: 4px;
}

/* Align all controls to the bottom */
.control-group > *:last-child {
    margin-top: auto;
}

/* Make buttons and selects have consistent height */
.control-group select,
.control-group button,
.control-group .home-button {
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    padding: 0 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid #e0e0e0;
    background-color: #f8f9fa;
    color: #2c3e50;
}

.control-group .home-button:hover {
    background-color: #e9ecef;
    border-color: #ced4da;
}

.control-group .home-button:active {
    background-color: #dee2e6;
    transform: translateY(1px);
}

.control-group .home-button svg {
    margin-right: 8px;
}

/* Special case for toggle switch */
.switch {
    margin-top: 4px;
}

/* Button group alignment */
.control-group:has(button) {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    height: 100%;
    margin: 0;
    padding: 0;
}

/* Align buttons with other controls */
.control-group button {
    margin: 0;
    height: 40px; /* Match select height */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    transform: translateY(0);
}

/* Specific alignment for blocked button */
#blocked-btn-container {
    height: 100%;
    display: flex;
    align-items: center;
    margin: 0;
    padding: 0;
    /* Remove opacity and visibility from here */
}

/* This will be controlled by the 'visible' class */
#blocked-btn-container:not(.visible) {
    display: none;
}

#check-blocked-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 40px;
    padding: 0 16px;
}

.control-group label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}



.controls select,
.controls button {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.controls select:hover,
.controls button:hover {
    border-color: var(--primary-color);
}

.controls select:focus,
.controls button:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.controls button.secondary {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.controls button.secondary:hover {
    background-color: var(--bg-secondary);
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 100%;
    height: 34px;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
    background-color: #ccc;
    border-radius: 24px;
    transition: .4s;
    margin-right: 8px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:focus + .slider {
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.5);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.switch .label {
    margin-left: 8px;
    font-size: 0.875rem;
    color: var(--text-primary);
}

select {
    background-color: white;
    border: 1px solid #e0e0e0;
    color: #2c3e50;
    min-width: 180px;
    max-width: 100%;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%232c3e50' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding: 0.5rem 2.5rem 0.5rem 0.75rem;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}

select:hover {
    border-color: #bdc3c7;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

select:focus {
    outline: none;
    border-color: #4a6fa5;
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.2);
}

button {
    background-color: #4a6fa5;
    color: white;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 111, 165, 0.3);
    background-color: #3a5f8a;
}

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

button.secondary {
    background-color: #f8f9fa;
    color: #2c3e50;
    border: 1px solid #e0e0e0;
}

button.secondary:hover {
    background-color: #e9ecef;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .controls {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .control-group {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    select, button {
        width: 100%;
    }
}

.game-container {
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
}

.game-info {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 300px;
    margin: 0 auto 15px;
    font-size: 1.2rem;
    font-weight: bold;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
    width: 100%;
}

.game-header h1 {
    margin: 0;
    font-size: 1.8rem;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.language-selector {
    position: relative;
    z-index: 10;
}

.language-selector select {
    padding: 8px 12px 8px 32px;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    background-color: #fff;
    font-size: 0.9rem;
    color: var(--text-color);
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left 12px top 50%;
    background-size: 14px;
    padding-left: 36px;
    height: 40px;
    transition: all 0.2s ease;
}

.language-selector select:hover {
    border-color: #bdbdbd;
}

.language-selector select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(74, 111, 165, 0.2);
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .game-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .language-selector {
        align-self: flex-end;
    }
    
    .game-header h1 {
        font-size: 1.5rem;
    }
}

.board {
    display: grid;
    grid-template-columns: repeat(var(--size, 5), 1fr);
    gap: 0;
    background-color: #999;
    border: 2px solid #333;
    max-width: 90vmin;
    width: 100%;
    aspect-ratio: 1/1;
    margin: 0 auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.cell {
    background-color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    aspect-ratio: 1/1;
}

/* Chessboard pattern */
.board {
    --light: #f0d9b5;
    --dark: #b58863;
    display: grid;
    grid-template-columns: repeat(var(--size, 5), 1fr);
    width: 100%;
    height: 100%;
    background-color: var(--light);
}

/* Default to light squares */
.cell {
    aspect-ratio: 1;
    background-color: var(--light);
    position: relative;
}

/* Dark squares - applied by JavaScript */
.cell.dark {
    background-color: var(--dark) !important;
}

/* Visited cells - semi-transparent overlay */
.cell.visited {
    background-color: rgba(76, 175, 80, 0.5) !important;
}

/* Knight's position */
.cell.knight {
    background: linear-gradient(135deg, #4a6fa5, #3a5f8a) !important;
    color: white;
    position: relative;
}

/* Knight icon */
.cell.knight::after {
    content: '♞';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem; /* Increased from default */
    line-height: 1;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

/* Valid moves */
.cell.valid-move {
    background-color: rgba(156, 204, 101, 0.7) !important;
}

/* Visited cells */
.cell.visited {
    background-color: #e8f4f8; /* Light blue background */
    position: relative;
    color: #2c6b8c;
    font-weight: bold;
    font-size: 0.8em;
    transition: all 0.3s ease;
    border: 1px solid #b8d8e8;
}

.cell.visited::before {
    content: attr(data-move-number);
    position: absolute;
    top: 3px;
    left: 4px;
    font-size: 0.7em;
    font-weight: bold;
    color: #2c6b8c;
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: 3px;
    padding: 1px 3px;
    min-width: 12px;
    text-align: center;
}

.cell.valid-move {
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

/* Valid move indicators */
.cell.valid-move {
    position: relative;
    cursor: pointer;
}

.cell.valid-move::after {
    content: '';
    position: absolute;
    top: 5%;
    left: 5%;
    right: 5%;
    bottom: 5%;
    border: 2px solid #4CAF50;
    border-radius: 6px;
    pointer-events: none;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.3);
    animation: pulse 1.5s infinite;
    background-color: rgba(76, 175, 80, 0.1);
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(1); opacity: 0.7; }
}

/* Knight's current position */
.cell.knight {
    background: linear-gradient(135deg, #4a6fa5, #3a5f8a) !important;
    color: white;
    font-weight: bold;
    z-index: 2;
    box-shadow: 0 0 15px rgba(74, 111, 165, 0.8);
    transform: scale(0.95);
}

/* Valid moves */
.cell.valid-move {
    background-color: rgba(156, 204, 101, 0.7) !important;
    cursor: pointer;
    box-shadow: 0 0 0 2px #4caf50;
}

.cell.valid-move:hover {
    background-color: rgba(102, 187, 106, 0.9) !important;
    transform: scale(0.95);
}

.cell.knight::after {
    content: '♞';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1.1);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.7);
}

.message {
    min-height: 24px;
    margin-top: 10px;
    font-weight: bold;
    text-align: center;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .controls {
        flex-direction: column;
        align-items: center;
    }
    
    .control-group {
        width: 100%;
        justify-content: center;
    }
    
    select, button {
        width: 100%;
        max-width: 200px;
    }
}

/* Snackbar Notification */
.snackbar {
    visibility: hidden;
    min-width: 250px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 4px;
    padding: 16px;
    position: fixed;
    z-index: 1000;
    left: 50%;
    bottom: 30px;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s, bottom 0.3s;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.snackbar.show {
    visibility: visible;
    opacity: 1;
    bottom: 40px;
}

.snackbar.success {
    background-color: #4caf50;
}

.snackbar.warning {
    background-color: #ff9800;
}

.snackbar.error {
    background-color: #f44336;
}

.snackbar.info {
    background-color: #2196f3;
}

/* Modal overlay */
.game-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.75);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease-in-out;
    backdrop-filter: blur(5px);
}

.game-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    max-width: 90%;
    width: 400px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    transform: translateY(20px);
    transition: transform 0.3s ease-out;
    animation: modalFadeIn 0.3s ease-out forwards;
}

@keyframes modalFadeIn {
    to {
        transform: translateY(0);
    }
}

.modal h2 {
    margin-top: 0;
    color: #2c3e50;
    font-size: 2rem;
    margin-bottom: 1rem;
}

.modal p {
    font-size: 1.2rem;
    color: #34495e;
    margin-bottom: 2rem;
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.modal-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: #4a6fa5;
    color: white;
}

.modal-btn.secondary {
    background-color: #f0f0f0;
    color: #333;
}

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

.modal-btn:active {
    transform: translateY(0);
}

/* Accessibility focus styles */
button:focus, select:focus {
    outline: 3px solid #4a9ae9;
    outline-offset: 2px;
}

/* Disabled state */
button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Hide utility */
.hidden {
    display: none !important;
}
