body {
    font-family: Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    background-color: #f0f0f0;
    overflow-x: hidden;
}

.game-container {
    max-width: 90vw;
    padding: 20px;
    text-align: center;
}

h1 {
    font-size: clamp(1.5rem, 5vw, 2rem);
    margin-bottom: 20px;
}

.input-section {
    margin-bottom: 20px;
}

#textInput {
    width: 100%;
    max-width: 500px;
    height: 100px;
    margin-bottom: 10px;
    font-size: 16px;
    padding: 10px;
    resize: none;
}

button {
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    margin: 5px;
}

button:hover {
    background-color: #0056b3;
}

.timer {
    font-size: clamp(1rem, 4vw, 1.2rem);
    margin-bottom: 20px;
}

.game-section {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
}

#wordList {
    flex: 1;
    min-width: 200px;
    max-width: 300px;
    text-align: left;
}

#wordList div {
    font-size: clamp(1rem, 3vw, 1.1rem);
    margin: 5px 0;
}

#wordList .found {
    color: red;
    text-decoration: line-through;
}

#puzzleGrid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 2px;
    width: min(90vw, 480px);
    max-width: 480px;
    aspect-ratio: 1;
}

.cell {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: white;
    border: 1px solid #ccc;
    font-size: clamp(0.9rem, 3vw, 1rem);
    text-transform: uppercase;
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
}

.cell.selected {
    background-color: #e0e0e0;
}

.cell.correct {
    background-color: rgba(255, 0, 0, 0.2);
    border: 2px solid red;
}

.cell.auto-solved {
    background-color: rgba(0, 255, 0, 0.2);
    border: 2px solid green;
}

.popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
}

.popup-content {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    max-width: 80%;
}

.popup-content h2 {
    margin: 0 0 10px;
}

.popup-content button {
    margin-top: 10px;
}

@media (max-width: 600px) {
    .game-section {
        flex-direction: column;
        align-items: center;
    }

    #puzzleGrid {
        width: 90vw;
        max-width: 360px;
    }

    #wordList {
        text-align: center;
        max-width: 100%;
    }
}