.wordsearch-body {
    background-color: #F8C8DC;
    min-height: 100vh;
}

.wordsearch-wrap {
    max-width: 760px;
    margin: 0 auto;
    padding: 0 16px 40px;
}

.wordsearch-title {
    text-align: center;
    color: white;
    font-family: 'Playfair Display', serif;
    font-size: 40px;
    font-weight: 700;
    margin: 8px 0 4px;
}

.wordsearch-subtitle {
    text-align: center;
    color: white;
    font-family: 'Playfair Display', serif;
    font-size: 22px;
    font-style: italic;
    margin: 0 0 6px;
    min-height: 28px;
}

.wordsearch-instructions {
    text-align: center;
    color: white;
    font-family: 'Playfair Display', serif;
    font-size: 16px;
    margin: 0 0 18px;
    opacity: 0.9;
}

.board-wrap {
    position: relative;
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    background-color: #fff;
    border-radius: 14px;
    padding: 10px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    aspect-ratio: 1 / 1;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.ws-board {
    position: relative;
    width: 100%;
    height: 100%;
    display: grid;
    gap: 0;
    z-index: 1;
}

.ws-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Playfair Display', serif;
    font-weight: 600;
    font-size: clamp(12px, 3.5vw, 22px);
    color: #2b1a22;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.1s ease, transform 0.1s ease;
    /* Prevent letter content from forcing rows taller than 1fr,
       which would push the SVG overlay out of alignment. */
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.ws-cell.selecting {
    background-color: rgba(176, 58, 108, 0.35);
}

.ws-overlay {
    position: absolute;
    inset: 10px;
    width: calc(100% - 20px);
    height: calc(100% - 20px);
    pointer-events: none;
    z-index: 2;
    overflow: visible;
}

.ws-found-line {
    fill: none;
    stroke-linecap: round;
    stroke-width: var(--line-stroke, 30);
    opacity: 0.40;
    animation: ws-pop 0.35s ease;
}

@keyframes ws-pop {
    0% { opacity: 0; stroke-width: 0; }
    100% { opacity: 0.40; }
}

.ws-words {
    list-style: none;
    padding: 0;
    margin: 18px auto 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px 14px;
    max-width: 560px;
}

.ws-words li {
    font-family: 'Playfair Display', serif;
    font-size: 17px;
    font-weight: 600;
    color: white;
    letter-spacing: 0.4px;
    text-align: center;
    padding: 4px 6px;
    border-radius: 6px;
    transition: opacity 0.2s ease;
}

.ws-words li.found {
    text-decoration: line-through;
    opacity: 0.55;
}

.ws-words li.revealed {
    text-decoration: line-through;
    opacity: 0.55;
    color: #ffe1ee;
    font-style: italic;
}

.wordsearch-message {
    text-align: center;
    color: white;
    font-family: 'Playfair Display', serif;
    font-size: 20px;
    margin: 18px 0 10px;
    min-height: 26px;
}

.wordsearch-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 6px;
}

.ws-btn {
    font-family: 'Playfair Display', serif;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.5px;
    padding: 11px 26px;
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, #ffffff 0%, #fce7ef 100%);
    color: #2b1a22;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(43, 26, 34, 0.18), inset 0 0 0 2px #2b1a22;
    transition: transform 0.15s, box-shadow 0.2s, background 0.2s, color 0.2s;
}

.ws-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #2b1a22 0%, #5a3b4a 100%);
    color: #fce7ef;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(43, 26, 34, 0.28), inset 0 0 0 2px #2b1a22;
}

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

.ws-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.ws-btn.primary {
    background: linear-gradient(135deg, #2b1a22 0%, #5a3b4a 100%);
    color: #fce7ef;
}

.ws-btn.primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #5a3b4a 0%, #7a5465 100%);
    color: white;
}

@media (max-width: 600px) {
    .wordsearch-title { font-size: 30px; }
    .wordsearch-subtitle { font-size: 17px; }
    .wordsearch-instructions { font-size: 14px; }
    .ws-words { grid-template-columns: repeat(2, minmax(0, 1fr)); font-size: 15px; }
    .ws-words li { font-size: 15px; }
    .wordsearch-message { font-size: 17px; }
}

@media (max-width: 380px) {
    .ws-cell { font-size: 13px; }
}
