:root {
    --primary-color: #2196F3;
    --secondary-color: #4CAF50;
    --error-color: #F44336;
    --grid-color: #333;
    --background-color: #f5f5f5;
    --cell-size: 50px;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1rem;
}

.game-container {
    background: white;
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 600px;
    animation: slideIn 0.6s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.header {
    text-align: center;
    margin-bottom: 2rem;
}

.header-top {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.title-section {
    text-align: center;
}

.github-link-header {
    position: absolute;
    top: 0.5rem;
    right: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: #666;
    text-decoration: none;
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
    border-radius: 15px;
    transition: all 0.3s ease;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
}

.github-link-header:hover {
    color: var(--primary-color);
    background: #fff;
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.2);
}

.github-link-header svg {
    transition: transform 0.3s ease;
}

.github-link-header:hover svg {
    transform: rotate(360deg);
}

h1 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 2.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

h3 {
    color: #666;
    font-weight: 400;
    font-size: 1rem;
    margin-bottom: 1.5rem;
    font-style: italic;
    opacity: 0.9;
}

/* Dropdown styling */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-btn {
    background: var(--primary-color);
    color: white;
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 160px;
    text-align: left;
}

.dropdown-btn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: white;
    min-width: 160px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    border-radius: 5px;
    z-index: 1000;
    top: 100%;
    left: 0;
    margin-top: 5px;
    overflow: hidden;
}

.dropdown-content a {
    color: var(--grid-color);
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    transition: background-color 0.3s ease;
    font-size: 1rem;
}

.dropdown-content a:hover {
    background-color: #f1f1f1;
}

.dropdown.active .dropdown-content {
    display: block;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

button {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    background: var(--primary-color);
    color: white;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

button:active {
    transform: translateY(0);
}

.sudoku-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 2px;
    margin: 2rem auto;
    padding: 10px;
    background: var(--grid-color);
    border-radius: 10px;
    width: fit-content;
}

.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    background: white;
    border: 1px solid #ddd;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.4rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 4px;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.cell:hover {
    background-color: #f0f8ff;
    transform: scale(1.05);
}

.cell.selected {
    background-color: var(--primary-color);
    color: white !important;
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(33, 150, 243, 0.5);
}

.cell.original {
    background-color: #f8f9fa;
    color: #2c3e50;
    font-weight: 900;
    font-family: 'Georgia', 'Times New Roman', serif;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.cell.original:hover {
    background-color: #f8f9fa;
    cursor: not-allowed;
    transform: none;
}

.cell.user-entered {
    color: var(--primary-color);
    font-weight: 600;
    font-family: 'Segoe UI', 'Arial', sans-serif;
    font-style: italic;
}

.cell.error {
    background-color: var(--error-color);
    color: white;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
}

.cell.hint {
    background-color: var(--secondary-color);
    color: white;
    animation: pulse 1s ease-in-out;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Add thick borders for 3x3 sections */
.cell:nth-child(3n) {
    border-right: 3px solid var(--grid-color);
}

.cell:nth-child(n+19):nth-child(-n+27),
.cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 3px solid var(--grid-color);
}

.instructions {
    margin: 1rem auto 0;
    max-width: 500px;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 4px solid var(--primary-color);
    overflow: hidden;
}

.instructions-header {
    padding: 0.8rem 1rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: var(--primary-color);
    user-select: none;
    transition: background-color 0.3s ease;
}

.instructions-header:hover {
    background-color: rgba(33, 150, 243, 0.1);
}

.toggle-icon {
    transition: transform 0.3s ease;
    display: inline-block;
    font-size: 0.8rem;
}

.instructions:not(.collapsed) .toggle-icon {
    transform: rotate(90deg);
}

.instructions-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    padding: 0 1rem;
}

.instructions:not(.collapsed) .instructions-content {
    max-height: 500px;
    padding: 0 1rem 1rem;
}

.instructions h4 {
    color: var(--primary-color);
    font-size: 1rem;
    margin: 1rem 0 0.5rem 0;
    text-align: left;
}

.instructions h4:first-child {
    margin-top: 0.5rem;
}

.instructions ol, .instructions ul {
    text-align: left;
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.instructions li {
    margin: 0.3rem 0;
    color: #555;
    font-size: 0.85rem;
    line-height: 1.4;
}

.instructions li strong {
    color: var(--primary-color);
}

.instructions ul ul {
    margin: 0.2rem 0;
    padding-left: 1rem;
}

.instructions ul ul li {
    font-size: 0.8rem;
    color: #666;
}

.how-to-play {
    margin-bottom: 1rem;
}

.game-rules {
    border-top: 1px solid #e0e0e0;
    padding-top: 0.5rem;
}



/* Responsive design */
@media (max-width: 768px) {
    :root {
        --cell-size: 40px;
    }
    
    .game-container {
        padding: 1rem;
        margin: 0.5rem;
    }
    
    h1 {
        font-size: 2.2rem;
    }
    
    h3 {
        font-size: 0.9rem;
    }
    
    .header-top {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
    }
    
    .github-link-header {
        position: static;
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
        order: -1;
    }
    
    .dropdown-btn {
        min-width: 130px;
        font-size: 0.85rem;
        padding: 0.7rem 1rem;
    }
    
    .dropdown-content {
        min-width: 130px;
    }
    
    .dropdown-content a {
        font-size: 0.85rem;
        padding: 10px 12px;
    }
    
    .controls {
        gap: 0.6rem;
        flex-wrap: wrap;
    }
    
    button {
        padding: 0.7rem 1rem;
        font-size: 0.85rem;
        min-width: 70px;
        touch-action: manipulation;
    }
    
    .sudoku-grid {
        gap: 1px;
        padding: 8px;
    }
    
    .instructions:not(.collapsed) .instructions-content {
        max-height: 600px;
    }
    
    .instructions h4 {
        font-size: 0.9rem;
    }
    
    .instructions li {
        font-size: 0.8rem;
    }
    
    .instructions ul ul li {
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    :root {
        --cell-size: 32px;
    }
    
    .game-container {
        padding: 0.8rem;
        margin: 0.2rem;
    }
    
    h1 {
        font-size: 1.8rem;
    }
    
    h3 {
        font-size: 0.8rem;
        margin-bottom: 1rem;
    }
    
    .dropdown-btn {
        min-width: 110px;
        font-size: 0.75rem;
        padding: 0.6rem 0.8rem;
    }
    
    .dropdown-content {
        min-width: 110px;
    }
    
    .dropdown-content a {
        padding: 8px 10px;
        font-size: 0.75rem;
    }
    
    .controls {
        gap: 0.4rem;
        justify-content: center;
    }
    
    button {
        padding: 0.6rem 0.8rem;
        font-size: 0.75rem;
        flex: 1;
        min-width: 60px;
        max-width: 80px;
    }
    
    .cell {
        font-size: 1.2rem;
    }
    
    .instructions:not(.collapsed) .instructions-content {
        max-height: 700px;
    }
    
    .instructions h4 {
        font-size: 0.85rem;
        margin: 0.8rem 0 0.4rem 0;
    }
    
    .instructions li {
        font-size: 0.75rem;
        margin: 0.25rem 0;
    }
    
    .instructions ul ul li {
        font-size: 0.7rem;
    }
}

@media (max-width: 360px) {
    :root {
        --cell-size: 28px;
    }
    
    h1 {
        font-size: 1.6rem;
    }
    
    .cell {
        font-size: 1.1rem;
    }
    
    .dropdown-btn {
        min-width: 100px;
        font-size: 0.7rem;
        padding: 0.5rem 0.7rem;
    }
    
    .dropdown-content {
        min-width: 100px;
    }
    
    .dropdown-content a {
        padding: 6px 8px;
        font-size: 0.7rem;
    }
    
    button {
        padding: 0.5rem 0.7rem;
        font-size: 0.7rem;
    }
}
