:root{

    --ws-bg:#181818;

    --grid-color:#444444;

    --letter-color:#ffffff;

    --found-color:#4f46e5;

}

/* ==========================================
   INPUTS
========================================== */

input,
select,
textarea{

    width:100%;

    padding:10px;

    border-radius:8px;

    border:1px solid #333;

    background:#1b1b1b;

    color:#fff;

    box-sizing:border-box;

    font-size:15px;

}

textarea{

    resize:vertical;

    min-height:260px;

    font-family:inherit;

}

/* ==========================================
   BUTTONS
========================================== */

.btn-group{

    margin-top:20px;

    display:flex;
    flex-direction:column;
    gap:8px;

    overflow:hidden;   /* ✅ removes scroll */

}

.btn-group button{

    width:100%;
    margin:0;

}

/* ==========================================
   SETTINGS
========================================== */

.settings-group{

    margin-top:20px;

    padding:18px;

    border-radius:10px;

    border:1px solid #2d2d2d;

}

.settings-group h3{

    margin:0 0 15px;

    font-size:16px;

}

.settings-option{

    display:flex;

    align-items:center;

    gap:10px;

    margin-top:14px;

    cursor:pointer;

    color:#ddd;

    user-select:none;

    font-weight:500;

}

.settings-option:hover{

    color:#fff;

}

.settings-option input[type=checkbox]{

    width:auto;

    margin:0;

    accent-color:#4f46e5;

}

/* ==========================================
   WORD SEARCH CONTAINER
========================================== */

.wordsearch-container{

    display:flex;

    justify-content:center;

    align-items:center;

    margin-top:25px;

    margin-bottom:25px;
    overflow: visible; /* IMPORTANT */
    max-width:100%;

}

/* ==========================================
   BOARD
========================================== */

#wordSearchBoard{

    display:grid;
    gap:0;

    border:4px solid var(--grid-color);
    background:var(--ws-bg);

    border-radius:12px;
    overflow:hidden;

    box-shadow:
        0 0 25px rgba(79,70,229,.20),
        inset 0 0 15px rgba(255,255,255,.04);

    /* REMOVE fixed sizing */
    width: fit-content;
    height: fit-content;

}

/* ==========================================
   CELL
========================================== */

.ws-cell{

    display:flex;
    justify-content:center;
    align-items:center;

    width:100%;
    height:100%;

    border:1px solid var(--grid-color);

    background:transparent;

    color:var(--letter-color);

    font-size: var(--cell-font-size, 16px);

    font-weight:700;

    user-select:none;

    transition:.15s;

}

.ws-cell:hover{

    background:#252525;

}

.ws-cell.word{

    color:#ffffff;

}

.ws-cell.found{

    background:var(--found-color);

    color:#fff;
    transition: 0.2s;

}

.ws-cell.solve{

    animation:solveFlash .45s ease;

}

@keyframes solveFlash{

    0%{

        transform:scale(.85);

    }

    100%{

        transform:scale(1);

    }

}

/* ==========================================
   WORD LIST
========================================== */

.word-list-section{

    margin-top:20px;

}

.word-list-section h3{

    margin-bottom:15px;

}

#wordList{

    display:grid;

    grid-template-columns:repeat(auto-fit,minmax(120px,1fr));

    gap:10px;

}

.word-item{

    padding:8px 12px;

    border-radius:8px;

    background:#202020;

    border:1px solid #2f2f2f;

    text-align:center;

    font-weight:600;

    transition:.2s;

}

.word-item.found{

    background:var(--found-color);

    color:#fff;
    text-decoration: line-through;
    opacity: 0.6;

}

/* ==========================================
   STATS
========================================== */

.wordsearch-stats{

    margin-top:25px;

}

.stats-row{

    display:grid;

    grid-template-columns:1fr 140px;

    align-items:center;

    padding:12px 0;

    border-bottom:1px solid #2d2d2d;

}

.stats-row span{

    color:#ccc;

    font-weight:500;

}

.stats-row strong{

    display:block;

    text-align:right;

    font-weight:700;

}

/* ==========================================
   STATUS
========================================== */

.status-ready{

    color:#10b981;

}

.status-working{

    color:#f59e0b;

}

.status-solved{

    color:#22c55e;

}

.status-error{

    color:#ef4444;

}

/* ==========================================
   BOARD ANIMATION
========================================== */

.generating{

    animation:pulseGlow 1.2s infinite alternate;

}

@keyframes pulseGlow{

    from{

        box-shadow:

            0 0 20px rgba(79,70,229,.15),

            inset 0 0 10px rgba(255,255,255,.02);

    }

    to{

        box-shadow:

            0 0 35px rgba(79,70,229,.35),

            inset 0 0 25px rgba(255,255,255,.05);

    }

}

/* ==========================================
   FADE
========================================== */

.fadeIn{

    animation:fadeIn .25s ease;

}

@keyframes fadeIn{

    from{

        opacity:0;

        transform:translateY(10px);

    }

    to{

        opacity:1;

        transform:translateY(0);

    }

}

/* ==========================================
   RESPONSIVE
========================================== */

@media(max-width:1000px){

    .ws-cell{

        width:34px;

        height:34px;

        font-size:18px;

    }

}

@media(max-width:800px){

    .ws-cell{

        width:30px;

        height:30px;

        font-size:16px;

    }

}

@media(max-width:600px){

    .ws-cell{

        width:24px;

        height:24px;

        font-size:13px;

    }

    #wordList{

        grid-template-columns:repeat(2,1fr);

    }

}

@media(max-width:450px){

    .ws-cell{

        width:20px;

        height:20px;

        font-size:11px;

    }

}

/* ==========================================
   EXPORT MODE
========================================== */

.exporting{

    box-shadow:none !important;

}

/* ==========================================
   FORCE ALIGNMENT
========================================== */

#statGrid,
#statWords,
#statLetters,
#statFill,
#statDifficulty,
#status{

    display:inline-block !important;

    width:140px;

    text-align:right;

    font:700 16px/1 Arial,sans-serif;

}

.zoom-control{

    display:flex;
    align-items:center;
    gap:10px;

    margin-top:10px;

}

.board-viewport{
    width: 100%;
    height: auto;
    overflow: auto;
    padding: 20px;
    box-sizing: border-box;

    /* IMPORTANT: remove flex centering */
    display: block;
}

.board-inner{
    display: inline-block;
    transform-origin: top left;
    will-change: transform;
}

.color-setting{

    margin-bottom:18px;

}

.color-row{
    display:flex;
    align-items:center;
    gap:12px;
}

.color-row input[type="color"]{
    appearance:none;
    -webkit-appearance:none;

    display:block;

    width:58px;
    height:42px;

    padding:0;
    border:1px solid #333;
    border-radius:8px;

    background:none;
    cursor:pointer;
}

.color-row span{

    flex:1;

    padding:10px 14px;

    border-radius:8px;

    background:#202020;

    border:1px solid #333;

    color:#fff;

    font-family:monospace;

    font-size:14px;

    letter-spacing:1px;

}

.color-row input[type="color"]::-webkit-color-swatch-wrapper{
    padding:0;
}

.color-row input[type="color"]::-webkit-color-swatch{
    border:none;
    border-radius:6px;
}