* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Roboto', 'Arial', sans-serif;
}

body {
    background-color: #f8f9fa;
    padding: 20px;
    color: #343a40;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    background-color: white;
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

h1 {
    text-align: center;
    color: #5a67d8;
    margin-bottom: 30px;
    font-weight: 700;
}

.input-section {
    margin-bottom: 30px;
}

textarea {
    width: 100%;
    padding: 15px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    resize: vertical;
    font-size: 16px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    transition: border-color 0.3s, box-shadow 0.3s;
}

textarea:focus {
    outline: none;
    border-color: #5a67d8;
    box-shadow: 0 0 0 3px rgba(90, 103, 216, 0.2);
}

.settings {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.size-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

label {
    font-weight: 600;
    color: #4a5568;
}

.slider-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 100%;
    max-width: 250px;
}

.slider {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: #e2e8f0;
    outline: none;
    border-radius: 4px;
    transition: all 0.2s;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #5a67d8;
    cursor: pointer;
    transition: all 0.2s;
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #5a67d8;
    cursor: pointer;
    transition: all 0.2s;
}

.slider:hover::-webkit-slider-thumb {
    transform: scale(1.1);
    background: #4c51bf;
}

.slider:hover::-moz-range-thumb {
    transform: scale(1.1);
    background: #4c51bf;
}

.slider-value {
    text-align: center;
    font-weight: 600;
    color: #5a67d8;
}

select {
    padding: 10px 15px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 16px;
    background-color: white;
    cursor: pointer;
    transition: border-color 0.3s, box-shadow 0.3s;
}

select:focus {
    outline: none;
    border-color: #5a67d8;
    box-shadow: 0 0 0 3px rgba(90, 103, 216, 0.2);
}

button {
    background-color: #5a67d8;
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.2s;
    box-shadow: 0 4px 6px rgba(90, 103, 216, 0.15);
}

button:hover {
    background-color: #4c51bf;
    transform: translateY(-2px);
    box-shadow: 0 7px 14px rgba(90, 103, 216, 0.2);
}

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

.hidden {
    display: none;
}

.buttons {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

#print-btn {
    background-color: #38b2ac;
    box-shadow: 0 4px 6px rgba(56, 178, 172, 0.15);
}

#print-btn:hover {
    background-color: #319795;
    box-shadow: 0 7px 14px rgba(56, 178, 172, 0.2);
}

#reset-btn {
    background-color: #f56565;
    box-shadow: 0 4px 6px rgba(245, 101, 101, 0.15);
}

#reset-btn:hover {
    background-color: #e53e3e;
    box-shadow: 0 7px 14px rgba(245, 101, 101, 0.2);
}

#show-words-btn {
    background-color: #ed8936;
    box-shadow: 0 4px 6px rgba(237, 137, 54, 0.15);
}

#show-words-btn:hover {
    background-color: #dd6b20;
    box-shadow: 0 7px 14px rgba(237, 137, 54, 0.2);
}

.grid-container {
    display: flex;
    gap: 40px;
    align-items: flex-start;
}

#word-search-grid {
    display: grid;
    grid-gap: 0;
    border: 3px solid #5a67d8;
    border-radius: 5px;
    overflow: hidden;
}

.grid-cell {
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e2e8f0;
    font-weight: bold;
    font-size: 18px;
    user-select: none;
    cursor: pointer;
    transition: all 0.2s;
}

.grid-cell:hover {
    background-color: #edf2f7;
}

.grid-cell.selected {
    background-color: #ebf4ff;
    color: #5a67d8;
}

.grid-cell.highlighted {
    color: #000;
}

#word-search-grid.no-grid-lines .grid-cell {
    border: none;
}

.word-list {
    flex: 1;
    background-color: #f8fafc;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.word-list h3 {
    margin-bottom: 15px;
    color: #5a67d8;
    font-weight: 600;
}

.current-word-display {
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    color: #5a67d8;
    margin-top: 15px;
    min-height: 27px;
    padding: 5px;
    border-radius: 4px;
    background-color: #f0f4ff;
}

.word-list ul {
    list-style-type: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}

.word-list li {
    padding: 8px 12px;
    font-size: 16px;
    border-radius: 4px;
    background-color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.2s;
}

.word-list li.found {
    background-color: #c6f6d5;
    color: #2f855a;
    text-decoration: line-through;
    font-weight: 600;
}

.puzzle-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 10px;
}

.tab-btn {
    background-color: #e2e8f0;
    color: #4a5568;
    border: none;
    padding: 8px 16px;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.2s;
}

.tab-btn.active {
    background-color: #5a67d8;
    color: white;
}

.tab-btn:hover:not(.active) {
    background-color: #cbd5e0;
}

.puzzle-tab {
    display: none;
}

.puzzle-tab.active {
    display: block;
}

#generate-sudoku-btn {
    background-color: #5a67d8;
    box-shadow: 0 4px 6px rgba(90, 103, 216, 0.15);
}

#generate-sudoku-btn:hover {
    background-color: #4c51bf;
    box-shadow: 0 7px 14px rgba(90, 103, 216, 0.2);
}

#print-sudoku-btn {
    background-color: #38b2ac;
    box-shadow: 0 4px 6px rgba(56, 178, 172, 0.15);
}

#print-sudoku-btn:hover {
    background-color: #319795;
    box-shadow: 0 7px 14px rgba(56, 178, 172, 0.2);
}

#solve-sudoku-btn {
    background-color: #ed8936;
    box-shadow: 0 4px 6px rgba(237, 137, 54, 0.15);
}

#solve-sudoku-btn:hover {
    background-color: #dd6b20;
    box-shadow: 0 7px 14px rgba(237, 137, 54, 0.2);
}

#new-sudoku-btn {
    background-color: #667eea;
    box-shadow: 0 4px 6px rgba(102, 126, 234, 0.15);
}

#new-sudoku-btn:hover {
    background-color: #5a67d8;
    box-shadow: 0 7px 14px rgba(102, 126, 234, 0.2);
}

#reset-sudoku-btn {
    background-color: #f56565;
    box-shadow: 0 4px 6px rgba(245, 101, 101, 0.15);
}

#reset-sudoku-btn:hover {
    background-color: #e53e3e;
    box-shadow: 0 7px 14px rgba(245, 101, 101, 0.2);
}

#sudoku-grid {
    display: grid;
    gap: 1px;
    margin: 0 auto;
    border: 3px solid #5a67d8;
    background-color: #5a67d8;
}

#sudoku-grid.grid4x4 {
    grid-template-columns: repeat(4, 40px);
    grid-template-rows: repeat(4, 40px);
}

#sudoku-grid.grid6x6 {
    grid-template-columns: repeat(6, 40px);
    grid-template-rows: repeat(6, 40px);
}

#sudoku-grid.grid9x9 {
    grid-template-columns: repeat(9, 40px);
    grid-template-rows: repeat(9, 40px);
}

.sudoku-cell.grid4x4:nth-child(2n):not(:nth-child(4n)) {
    border-right: 2px solid #5a67d8;
}

.sudoku-cell.grid4x4:nth-child(n+5):nth-child(-n+8) {
    border-bottom: 2px solid #5a67d8;
}

.sudoku-cell.grid9x9:nth-child(3n):not(:nth-child(9n)) {
    border-right: 2px solid #5a67d8;
}

.sudoku-cell.grid9x9:nth-child(n+19):nth-child(-n+27),
.sudoku-cell.grid9x9:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 2px solid #5a67d8;
}

.sudoku-cell.grid6x6:nth-child(3n):not(:nth-child(6n)) {
    border-right: 2px solid #5a67d8;
}

.sudoku-cell.grid6x6:nth-child(n+7):nth-child(-n+12),
.sudoku-cell.grid6x6:nth-child(n+19):nth-child(-n+24) {
    border-bottom: 2px solid #5a67d8;
}

.sudoku-cell {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: white;
    font-weight: bold;
    font-size: 18px;
    user-select: none;
    position: relative;
}

.sudoku-cell.filled {
    color: #5a67d8;
}

.sudoku-cell.solution {
    color: #38b2ac;
}

.sudoku-cell.error {
    color: #e53e3e;
}

.sudoku-cell[contenteditable="true"] {
    cursor: pointer;
}

.sudoku-cell[contenteditable="true"]:hover {
    background-color: #f7fafc;
}

.sudoku-cell[contenteditable="true"]:focus {
    outline: none;
    background-color: #ebf8ff;
    box-shadow: inset 0 0 0 2px #4299e1;
}

.difficulty-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sudoku-container {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

#crossword-grid {
    display: grid;
    gap: 1px;
    margin: 0 auto;
    border: 3px solid #5a67d8;
    background-color: white;
}

.crossword-cell {
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e2e8f0;
    font-weight: bold;
    font-size: 16px;
    background-color: white;
    position: relative;
}

.crossword-cell.filled {
    background-color: white;
}

.crossword-cell.blocked {
    background-color: #2d3748;
}

.crossword-cell.hint {
    background-color: #ebf4ff;
    color: #5a67d8;
}

.crossword-cell[contenteditable="true"] {
    cursor: text;
}

.crossword-cell[contenteditable="true"]:focus {
    outline: none;
    background-color: #ebf8ff;
    box-shadow: inset 0 0 0 2px #4299e1;
}

.crossword-cell.correct {
    background-color: #c6f6d5;
    color: #2f855a;
}

.crossword-cell.error {
    color: #e53e3e;
}

.crossword-container {
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    gap: 40px;
    margin-top: 20px;
}

.code-list {
    flex: 1;
    max-width: 400px;
    background-color: #f8fafc;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.code-list h3 {
    margin-bottom: 15px;
    color: #5a67d8;
    font-weight: 600;
}

.code-list ul {
    list-style-type: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}

.code-list li {
    padding: 8px 12px;
    font-size: 16px;
    border-radius: 4px;
    background-color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.2s;
}

.code-list li.found {
    background-color: #c6f6d5;
    color: #2f855a;
    text-decoration: line-through;
    font-weight: 600;
}

.cell-number {
    position: absolute;
    top: 2px;
    left: 2px;
    font-size: 10px;
    color: #4a5568;
}

#print-crossword-btn {
    background-color: #38b2ac;
    box-shadow: 0 4px 6px rgba(56, 178, 172, 0.15);
}

#print-crossword-btn:hover {
    background-color: #319795;
    box-shadow: 0 7px 14px rgba(56, 178, 172, 0.2);
}

#show-codes-btn {
    background-color: #ed8936;
    box-shadow: 0 4px 6px rgba(237, 137, 54, 0.15);
}

#show-codes-btn:hover {
    background-color: #dd6b20;
    box-shadow: 0 7px 14px rgba(237, 137, 54, 0.2);
}

#new-crossword-btn {
    background-color: #667eea;
    box-shadow: 0 4px 6px rgba(102, 126, 234, 0.15);
}

#new-crossword-btn:hover {
    background-color: #5a67d8;
    box-shadow: 0 7px 14px rgba(102, 126, 234, 0.2);
}

#reset-crossword-btn {
    background-color: #f56565;
    box-shadow: 0 4px 6px rgba(245, 101, 101, 0.15);
}

#reset-crossword-btn:hover {
    background-color: #e53e3e;
    box-shadow: 0 7px 14px rgba(245, 101, 101, 0.2);
}

#auto-generate-codes-btn {
    background-color: #4c51bf;
    box-shadow: 0 4px 6px rgba(76, 81, 191, 0.15);
    margin-right: 10px;
}

#auto-generate-codes-btn:hover {
    background-color: #434190;
    box-shadow: 0 7px 14px rgba(76, 81, 191, 0.2);
}

@media print {
    body {
        background-color: white;
        padding: 0;
    }
    
    .container {
        box-shadow: none;
        padding: 0;
    }
    
    .input-section, .buttons {
        display: none;
    }
    
    #output-section {
        display: block !important;
    }
    
    .grid-cell.highlighted {
        background-color: white !important;
        color: black !important;
    }
    
    .grid-cell.selected {
        background-color: white !important;
        color: black !important;
    }
    
    #word-search-grid.no-grid-lines .grid-cell {
        border: none !important;
    }
    
    .word-list li.found {
        text-decoration: none;
        background-color: white;
        color: black;
    }
    
    #sudoku-output-section {
        display: block !important;
    }
    
    .sudoku-cell.solution {
        color: white !important;
    }
}

@media (max-width: 768px) {
    .grid-container {
        flex-direction: column;
    }
    
    .buttons {
        flex-direction: column;
    }
    
    button {
        width: 100%;
    }
    
    .settings {
        flex-direction: column;
        align-items: stretch;
    }
}