.elg-wordsearch {
    --elg-wsh-ink: #172033;
    --elg-wsh-muted: #64748b;
    --elg-wsh-blue: #2563eb;
    --elg-wsh-cyan: #06b6d4;
    --elg-wsh-green: #22c55e;
    --elg-wsh-orange: #f97316;
    max-width: 1060px;
    margin: 24px auto;
    padding: 20px;
    border: 1px solid #dbeafe;
    border-radius: 16px;
    background: linear-gradient(145deg, #f8fafc 0%, #eef2ff 52%, #ecfeff 100%);
    color: var(--elg-wsh-ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    box-shadow: 0 18px 45px rgba(30, 41, 59, .12);
    box-sizing: border-box;
}

.elg-wordsearch *,
.elg-wordsearch *::before,
.elg-wordsearch *::after {
    box-sizing: border-box;
}

.elg-wordsearch [hidden] {
    display: none !important;
}

.elg-wsh-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.elg-wsh-title-wrap {
    min-width: 0;
}

.elg-wsh-kicker {
    display: block;
    margin-bottom: 3px;
    color: var(--elg-wsh-cyan);
    font-size: .76rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.elg-wsh-title {
    margin: 0;
    color: #1e3a8a;
    font-size: 1.3rem;
    font-weight: 900;
    line-height: 1.2;
}

.elg-wsh-stats {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    color: #334155;
    font-size: .92rem;
    font-weight: 800;
}

.elg-wsh-stats span,
.elg-wsh-chip {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    background: rgba(255, 255, 255, .84);
}

.elg-wsh-stats b {
    color: var(--elg-wsh-blue);
}

.elg-wsh-icon-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    background: #ffffff;
    color: var(--elg-wsh-blue);
    cursor: pointer;
    transition: background .2s ease, transform .1s ease;
}

.elg-wsh-icon-btn:hover,
.elg-wsh-icon-btn:focus-visible {
    background: #eff6ff;
    outline: none;
}

.elg-wsh-icon-btn:active {
    transform: scale(.96);
}

.elg-wsh-icon-btn svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}
.elg-wsh-icon-btn svg path,
.elg-wsh-icon-btn svg line,
.elg-wsh-icon-btn svg circle {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.elg-wsh-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.elg-wsh-btn {
    min-height: 42px;
    padding: 10px 18px;
    border: 0;
    border-radius: 12px;
    background: linear-gradient(180deg, #3b82f6, #2563eb);
    color: #ffffff;
    font: inherit;
    font-size: .95rem;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(37, 99, 235, .18);
    transition: filter .2s ease, transform .1s ease;
}

.elg-wsh-btn:hover,
.elg-wsh-btn:focus-visible {
    filter: brightness(1.05);
    outline: none;
}

.elg-wsh-btn:active {
    transform: scale(.96);
}

.elg-wsh-chip {
    color: #334155;
    font-size: .86rem;
    font-weight: 800;
}

.elg-wsh-btn-secondary {
    background: #e2e8f0;
    color: #334155;
    box-shadow: none;
}

.elg-wsh-btn-secondary:hover,
.elg-wsh-btn-secondary:focus-visible {
    background: #cbd5e1;
}

.elg-wsh-setup {
    padding: 20px;
    border: 1px solid rgba(191, 219, 254, .9);
    border-radius: 14px;
    background: rgba(255, 255, 255, .9);
    box-shadow: 0 12px 26px rgba(37, 99, 235, .08);
}

.elg-wsh-setup-label {
    display: block;
    margin-bottom: 8px;
    color: #1e3a8a;
    font-size: 1rem;
    font-weight: 900;
}

.elg-wsh-setup-input {
    width: 100%;
    min-height: 190px;
    padding: 12px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    background: #ffffff;
    color: #172033;
    font: inherit;
    font-size: .96rem;
    font-weight: 800;
    line-height: 1.5;
    resize: vertical;
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.elg-wsh-setup-input:focus,
.elg-wsh-setup-options input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

.elg-wsh-setup-help {
    margin-top: 8px;
    color: #64748b;
    font-size: .88rem;
    font-weight: 700;
    line-height: 1.45;
}

.elg-wsh-setup-options {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) repeat(2, minmax(160px, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.elg-wsh-setup-options label {
    min-height: 50px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid #dbeafe;
    border-radius: 12px;
    background: #ffffff;
    color: #334155;
    font-size: .9rem;
    font-weight: 800;
}

.elg-wsh-setup-options label:first-child {
    align-items: flex-start;
    flex-direction: column;
}

.elg-wsh-setup-options input[type="number"] {
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    color: #172033;
    font: inherit;
    font-weight: 800;
    outline: none;
}

.elg-wsh-setup-options input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin: 0;
    accent-color: #2563eb;
}

.elg-wsh-setup-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 14px;
}

.elg-wsh-setup-message {
    min-height: 24px;
    margin-top: 10px;
    color: #dc2626;
    font-size: .94rem;
    font-weight: 800;
    text-align: center;
}

.elg-wsh-message {
    min-height: 28px;
    margin-bottom: 10px;
    color: #475569;
    font-size: .98rem;
    font-weight: 800;
    text-align: center;
}

.elg-wsh-message.success {
    color: #15803d;
}

.elg-wsh-message.error {
    color: #dc2626;
}

.elg-wsh-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 250px;
    gap: 18px;
    align-items: start;
}

.elg-wsh-board-wrap,
.elg-wsh-list-panel {
    border: 1px solid rgba(191, 219, 254, .9);
    border-radius: 14px;
    background: rgba(255, 255, 255, .88);
    box-shadow: 0 12px 26px rgba(37, 99, 235, .08);
}

.elg-wsh-board-wrap {
    padding: 14px;
    overflow: auto;
}

.elg-wsh-board {
    --cell-size: 42px;
    display: grid;
    grid-template-columns: repeat(var(--grid-size), var(--cell-size));
    justify-content: center;
    gap: 4px;
    width: max-content;
    min-width: 100%;
    margin: 0 auto;
    touch-action: none;
    user-select: none;
}

.elg-wsh-cell {
    width: var(--cell-size);
    height: var(--cell-size);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #dbeafe;
    border-radius: 9px;
    background: #ffffff;
    color: #1e293b;
    font: inherit;
    font-size: 1.05rem;
    font-weight: 900;
    line-height: 1;
    cursor: pointer;
    transition: background .16s ease, color .16s ease, transform .1s ease, box-shadow .16s ease;
    -webkit-tap-highlight-color: transparent;
}

.elg-wsh-cell:hover,
.elg-wsh-cell:focus-visible {
    background: #eff6ff;
    outline: none;
}

.elg-wsh-cell.is-selecting {
    background: #fde68a;
    border-color: #f59e0b;
    color: #7c2d12;
    transform: scale(.96);
}

.elg-wsh-cell.is-found {
    background: linear-gradient(160deg, #4ade80, #16a34a);
    border-color: rgba(22, 163, 74, .55);
    color: #ffffff;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, .16);
}

.elg-wsh-cell.is-found:nth-child(4n + 1) {
    background: linear-gradient(160deg, #38bdf8, #2563eb);
}

.elg-wsh-cell.is-found:nth-child(4n + 2) {
    background: linear-gradient(160deg, #fb7185, #ec4899);
}

.elg-wsh-cell.is-found:nth-child(4n + 3) {
    background: linear-gradient(160deg, #fbbf24, #f97316);
}

.elg-wsh-list-panel {
    padding: 14px;
}

.elg-wsh-list-title {
    margin-bottom: 10px;
    color: #1e3a8a;
    font-size: .95rem;
    font-weight: 900;
    text-transform: uppercase;
}

.elg-wsh-word-list {
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
    list-style: none;
}

.elg-wsh-word {
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #ffffff;
    color: #334155;
    font-size: .92rem;
    font-weight: 900;
}

.elg-wsh-word.is-found {
    border-color: rgba(34, 197, 94, .38);
    background: #dcfce7;
    color: #15803d;
    text-decoration: line-through;
}

.elg-wsh-word-mark {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #e2e8f0;
    color: transparent;
    font-size: .76rem;
}

.elg-wsh-word.is-found .elg-wsh-word-mark {
    background: #22c55e;
    color: #ffffff;
}

.elg-wordsearch:fullscreen,
.elg-wordsearch.is-fullscreen {
    width: 100vw;
    max-width: none;
    min-height: 100vh;
    margin: 0;
    padding: 24px;
    border: 0;
    border-radius: 0;
    overflow: auto;
}

.elg-wordsearch:fullscreen .elg-wsh-layout,
.elg-wordsearch.is-fullscreen .elg-wsh-layout {
    max-width: 1180px;
    margin: 0 auto;
}

@media (max-width: 900px) {
    .elg-wsh-layout {
        grid-template-columns: 1fr;
    }

    .elg-wsh-list-panel {
        order: -1;
    }

    .elg-wsh-word-list {
        grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
    }
}

@media (max-width: 640px) {
    .elg-wordsearch {
        margin: 16px auto;
        padding: 14px;
    }

    .elg-wsh-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .elg-wsh-stats,
    .elg-wsh-toolbar {
        width: 100%;
    }

    .elg-wsh-stats span,
    .elg-wsh-chip,
    .elg-wsh-btn {
        flex: 1 1 auto;
        justify-content: center;
    }

    .elg-wsh-board-wrap {
        padding: 10px;
    }

    .elg-wsh-setup {
        padding: 16px;
    }

    .elg-wsh-setup-options {
        grid-template-columns: 1fr;
    }

    .elg-wsh-board {
        --cell-size: 34px;
        gap: 3px;
    }

    .elg-wsh-cell {
        border-radius: 8px;
        font-size: .94rem;
    }
}

@media (max-width: 420px) {
    .elg-wsh-board {
        --cell-size: 30px;
        gap: 2px;
    }

    .elg-wsh-cell {
        border-radius: 7px;
        font-size: .84rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .elg-wordsearch *,
    .elg-wordsearch *::before,
    .elg-wordsearch *::after {
        animation: none !important;
        transition: none !important;
    }
}
