html {
    touch-action: manipulation;
}

#puzzle-grid {
    display: grid;
    grid-template-columns: repeat(3, 80px);
    grid-template-rows: repeat(3, 80px);
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
    transition: opacity 0.2s;
}

.grid-cell {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    border: 2px solid #333;
    border-radius: 8px;
    user-select: none;
    transition: background-color 0.2s, border 0.2s;
}

.grid-cell.highlighted {
    border: 3px solid #e17055;
}

.grid-cell.unused {
    background-color: #f4f4f4;
}

.grid-cell.used-once {
    background-color: #ffeaa7;
}

.grid-cell.used-twice {
    background-color: #b2bec3;
}

.grid-cell.disabled {
    color: transparent;
}

.overlay {
    position: absolute;
    width: 70%;
    height: 70%;
    border: 3px solid #007BFF;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    pointer-events: none;
}

#current-word {
    text-align: center;
    font-size: 2.2rem;
    font-weight: bold;
    margin-bottom: 15px;
    min-height: 3rem;
    border: 2px solid #333;
    border-radius: 8px;
    padding: 8px 16px;
    width: 250px;
    background-color: #fffcee;
    margin: 0 auto 15px auto;
}

#current-word.disabled {
    pointer-events: none;
    opacity: 0.4;
}

#current-word.disabled .blinking-cursor {
    visibility: hidden;
}

.control-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.control-buttons.margin-top {
    margin-top: 20px;
}

.control-buttons.margin-bottom {
    margin-bottom: 20px;
}

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

.pulse {
    animation: pulse 0.3s ease;
}

#submitted-words {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    font-weight: bold;
    font-size: 1.4rem;
    margin-top: 20px;
}

.submitted-word-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 300px;
    margin: 10px 0;
    position: relative;
}

.submitted-word-text {
    flex-shrink: 0;
}

.submitted-word-duplicate {
    color: #A020F0;
}

.connector-line {
    flex-grow: 1;
    height: 2px;
    background-color: #555;
    margin: 0 10px;
}

.remove-word-btn {
    color: red;
    font-size: 1.4rem;
    cursor: pointer;
}

.blinking-cursor {
    font-weight: 100;
    font-size: 1.8rem;
    color: #333;
    animation: blink 1s step-start infinite;
}

@keyframes blink {
    50% { opacity: 0; }
}

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

.shake {
    animation: shake 0.3s;
}

#flash-message {
    text-align: center;
    font-size: 1.2rem;
    color: red;
    margin-bottom: 10px;
    height: 1.4rem;
}

.valid-word-section,
.winning-set-section {
    background-color: var(--bg-main);
    border: 2px solid var(--color-primary);
    border-radius: 12px;
    padding: 0.75rem;
    margin: 1rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.valid-word-section h3,
.winning-set-section h3 {
    margin: 0 0 0.5rem 0;
    color: var(--color-primary);
    font-size: 1.1rem;
    border-bottom: 1px solid var(--color-primary);
    padding-bottom: 0.3rem;
}

.valid-word-list,
.winning-set-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.valid-word-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.valid-word-list li {
    background: white;
    border: 1px solid var(--color-secondary);
    padding: 0.3rem 0.6rem;
    border-radius: 20px;
    color: var(--text-main);
    font-size: 0.9rem;
    line-height: 1;
    white-space: nowrap;
}

.winning-set-list li {
    background: var(--color-success);
    color: white;
    font-weight: 600;
    padding: 0.4rem 0.6rem;
    margin-bottom: 0.4rem;
    border-radius: 8px;
    font-size: 1rem;
}

@media (max-width: 600px) {
    .control-buttons {
        margin-bottom: 7px;
    }

    #submitted-words {
        font-size: 1.1rem;
        margin-top: 7px;
    }

    .submitted-word-row {
        max-width: 90vw;
        margin: 5px 0;
    }

    #current-word {
        font-size: 1.8rem;
        padding: 6px 10px;
        width: 200px;
    }

    #puzzle-grid {
        gap: 6px;
        grid-template-columns: repeat(3, 70px);
        grid-template-rows: repeat(3, 70px);
    }

    .grid-cell {
        font-size: 1.8rem;
    }
}