/* =========================================================
   SO‘Z QIDIRISH
   MAIN STYLES
   ========================================================= */


/* =========================================================
   1. VARIABLES
   ========================================================= */

:root {
    --bg: #f4f7fb;
    --card: #ffffff;

    --text: #152238;
    --muted: #68758a;

    --border: #dfe6ef;

    --primary: #2563eb;
    --primary-dark: #1d4ed8;

    --success: #16a34a;
    --danger: #dc2626;

    --cell: #f8fafc;
    --cell-hover: #e8f0ff;
    --selected: #bfdbfe;

    --radius: 18px;

    --shadow:
        0 14px 40px rgba(30, 55, 90, 0.08);
}


/* =========================================================
   2. RESET
   ========================================================= */

* {
    box-sizing: border-box;
}


body {
    margin: 0;

    min-height: 100vh;

    background: var(--bg);
    color: var(--text);

    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Arial,
        sans-serif;
}


button,
input,
select {
    font: inherit;
}


button {
    cursor: pointer;
}


/* =========================================================
   3. MAIN CONTAINER
   ========================================================= */

.app {
    width: min(
        1180px,
        calc(100% - 32px)
    );

    margin: 0 auto;

    padding: 28px 0 50px;
}


/* =========================================================
   4. HEADER
   ========================================================= */

.topbar,
.game-header {
    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 20px;
}


.topbar {
    margin-bottom: 24px;
}


/* =========================================================
   5. TYPOGRAPHY
   ========================================================= */

.eyebrow {
    margin-bottom: 7px;

    color: var(--primary);

    font-size: 11px;
    font-weight: 800;

    letter-spacing: 1.7px;
}


h1,
h2,
h3,
p {
    margin-top: 0;
}


h1 {
    margin-bottom: 5px;

    font-size: clamp(
        30px,
        5vw,
        46px
    );

    line-height: 1;
}


h2 {
    margin-bottom: 5px;

    font-size: 27px;
}


h3 {
    margin-bottom: 14px;
}


p {
    margin-bottom: 0;

    color: var(--muted);
}


/* =========================================================
   6. SCREENS
   ========================================================= */

.screen {
    display: none;
}


.screen.active {
    display: block;
}


/* =========================================================
   7. CARD
   ========================================================= */

.card {
    background: var(--card);

    border: 1px solid var(--border);
    border-radius: var(--radius);

    box-shadow: var(--shadow);
}


/* =========================================================
   8. SETUP CARD
   ========================================================= */

.setup-card {
    max-width: 720px;

    margin: 0 auto;

    padding: 28px;
}


.section-title {
    display: flex;

    align-items: flex-start;

    gap: 13px;

    margin-bottom: 27px;
}


.step {
    width: 34px;
    height: 34px;

    display: grid;
    place-items: center;

    flex: 0 0 34px;

    border-radius: 50%;

    background: #eaf2ff;
    color: var(--primary);

    font-weight: 800;
}


/* =========================================================
   9. LABELS
   ========================================================= */

label {
    display: block;

    margin-bottom: 8px;

    font-size: 13px;
    font-weight: 750;
}


/* =========================================================
   10. INPUTS / SELECTS
   ========================================================= */

input,
select {
    width: 100%;

    padding: 12px 13px;

    border: 1px solid var(--border);
    border-radius: 11px;

    background: #ffffff;
    color: var(--text);

    outline: none;

    transition:
        border-color 0.2s,
        box-shadow 0.2s;
}


input:focus,
select:focus {
    border-color: var(--primary);

    box-shadow:
        0 0 0 3px rgba(
            37,
            99,
            235,
            0.10
        );
}


/* =========================================================
   11. ALPHABET OPTION
   ========================================================= */

.alphabet-option {
    margin-top: 20px;
}


.field-hint {
    margin-top: 7px;

    font-size: 11px;

    line-height: 1.4;
}


/* =========================================================
   12. WORD INPUTS
   ========================================================= */

.words-head {
    display: flex;

    justify-content: space-between;
    align-items: center;

    margin-top: 22px;
}


.words-head label {
    margin: 0;
}


#word-count {
    color: var(--muted);

    font-size: 12px;
    font-weight: 700;
}


.word-inputs {
    display: grid;

    gap: 9px;

    margin: 9px 0 12px;
}


.word-row {
    display: flex;

    gap: 8px;
}


.word-row input {
    flex: 1;
}


/* =========================================================
   13. REMOVE WORD BUTTON
   ========================================================= */

.remove-word {
    width: 44px;

    border: 1px solid var(--border);
    border-radius: 11px;

    background: #ffffff;
    color: #8a96a8;

    font-size: 20px;
}


.remove-word:hover {
    color: var(--danger);

    border-color: #fecaca;
}


/* =========================================================
   14. BUTTONS
   ========================================================= */

.primary-btn,
.secondary-btn,
.ghost-btn {
    padding: 11px 17px;

    border-radius: 11px;

    font-weight: 800;

    border: 1px solid transparent;

    transition:
        background 0.2s,
        color 0.2s,
        transform 0.2s;
}


/* Primary */

.primary-btn {
    width: 100%;

    margin-top: 20px;

    background: var(--primary);
    color: #ffffff;

    box-shadow:
        0 7px 18px rgba(
            37,
            99,
            235,
            0.18
        );
}


.primary-btn:hover {
    background: var(--primary-dark);

    transform: translateY(-1px);
}


/* Secondary */

.secondary-btn {
    background: #eef4ff;

    color: var(--primary);

    border-color: #dce8ff;
}


.secondary-btn:hover {
    background: #e2ecff;
}


/* Ghost */

.ghost-btn {
    background: transparent;

    color: var(--muted);

    border-color: var(--border);
}


.ghost-btn:hover {
    background: #ffffff;

    color: var(--text);
}


/* =========================================================
   15. SETUP OPTIONS
   ========================================================= */

.setup-options {
    display: grid;

    grid-template-columns: 1fr 1fr;

    gap: 12px;

    margin-top: 22px;
}


.option-box {
    padding: 14px;

    border: 1px solid var(--border);
    border-radius: 13px;

    background: #fbfcfe;
}


.option-box label {
    margin-bottom: 7px;
}


/* =========================================================
   16. ERROR
   ========================================================= */

.error-message {
    min-height: 20px;

    margin-top: 13px;

    color: var(--danger);

    font-size: 13px;
    font-weight: 650;
}


/* =========================================================
   17. HEADER ACTIONS
   ========================================================= */

.header-actions {
    display: flex;

    flex-wrap: wrap;

    justify-content: flex-end;

    gap: 8px;
}


/* =========================================================
   18. PAGE LAYOUT
   ========================================================= */

.preview-layout,
.game-layout {
    display: grid;

    grid-template-columns:
        minmax(0, 1.4fr)
        minmax(280px, 0.6fr);

    gap: 18px;

    margin-top: 20px;
}


/* =========================================================
   19. BOARD CARD
   ========================================================= */

.board-card {
    padding: clamp(
        15px,
        3vw,
        26px
    );
}


/* =========================================================
   20. 12 × 12 BOARD
   ========================================================= */

.board {
    width: min(
        100%,
        620px
    );

    aspect-ratio: 1;

    margin: 0 auto;

    display: grid;

    grid-template-columns:
        repeat(12, 1fr);

    gap: 4px;

    user-select: none;
}


/* =========================================================
   21. BOARD CELL
   ========================================================= */

.cell {
    min-width: 0;
    min-height: 0;

    display: grid;
    place-items: center;

    padding: 0;

    border-radius: 7px;

    background: var(--cell);

    border: 1px solid #e8edf3;

    color: #a9adb4;

    font-size: clamp(
        13px,
        2vw,
        21px
    );

    font-weight: 850;

    line-height: 1;

    transition:
        background 0.12s,
        transform 0.12s,
        color 0.12s;
}


/* =========================================================
   22. GAME CELL
   ========================================================= */

.selectable-board .cell {
    cursor: pointer;
}


.selectable-board .cell:hover {
    background: var(--cell-hover);

    transform: scale(1.03);
}


/* =========================================================
   23. SELECTED CELL
   ========================================================= */

.cell.selected {
    background: var(--selected);

    color: #174ea6;

    transform: scale(1.03);
}


/* =========================================================
   24. FOUND CELL
   ========================================================= */

.cell.found {
    background: #dcfce7;

    color: var(--success);

    border-color: #bbf7d0;
}


/* =========================================================
   25. WRONG CELL
   ========================================================= */

.cell.wrong {
    background: #fee2e2;

    color: var(--danger);

    animation: shake 0.28s ease;
}


/* =========================================================
   26. ANIMATION
   ========================================================= */

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-4px);
    }

    75% {
        transform: translateX(4px);
    }
}


/* =========================================================
   27. WORD CARD
   ========================================================= */

.word-card {
    padding: 22px;

    display: flex;
    flex-direction: column;
}


.word-list {
    display: grid;

    gap: 8px;

    max-height: 520px;

    overflow: auto;
}


/* =========================================================
   28. WORD ITEM
   ========================================================= */

.word-item {
    display: flex;

    align-items: center;

    gap: 9px;

    padding: 11px 12px;

    border-radius: 10px;

    background: #f7f9fc;

    border: 1px solid #edf1f5;

    font-weight: 750;
}


/* =========================================================
   29. WORD CHECK
   ========================================================= */

.word-item .check {
    width: 23px;
    height: 23px;

    display: grid;
    place-items: center;

    flex: 0 0 23px;

    border-radius: 50%;

    background: #e7edf5;

    color: transparent;

    font-size: 13px;
}


/* =========================================================
   30. FOUND WORD
   ========================================================= */

.word-item.found {
    color: #8190a4;

    background: #f1faf4;

    text-decoration: line-through;
}


.word-item.found .check {
    background: #dcfce7;

    color: var(--success);
}


/* =========================================================
   31. GAME STATS
   ========================================================= */

.stats {
    display: flex;

    gap: 8px;
}


.stat {
    min-width: 88px;

    padding: 10px 13px;

    border-radius: 12px;

    background: #ffffff;

    border: 1px solid var(--border);

    text-align: center;
}


.stat span {
    display: block;

    color: var(--muted);

    font-size: 10px;
    font-weight: 750;

    text-transform: uppercase;
}


.stat strong {
    display: block;

    margin-top: 3px;

    font-size: 18px;
}


.timer-stat strong {
    color: var(--primary);
}


/* =========================================================
   32. SELECTION HINT
   ========================================================= */

.selection-hint {
    margin-top: 13px;

    padding: 10px 12px;

    border-radius: 10px;

    background: #f5f8fc;

    color: var(--muted);

    text-align: center;

    font-size: 12px;
}


/* =========================================================
   33. WORD CARD HEADER
   ========================================================= */

.word-card-title {
    display: flex;

    align-items: center;

    justify-content: space-between;
}


.word-card-title h3 {
    margin: 0;
}


#remaining-count {
    min-width: 28px;
    height: 28px;

    display: grid;
    place-items: center;

    border-radius: 50%;

    background: #eef4ff;

    color: var(--primary);

    font-size: 12px;
    font-weight: 850;
}


/* =========================================================
   34. RESULT CARD
   ========================================================= */

.result-card {
    max-width: 650px;

    margin: 35px auto 0;

    padding: 42px 30px;

    text-align: center;
}


.result-icon {
    width: 62px;
    height: 62px;

    margin: 0 auto 18px;

    display: grid;
    place-items: center;

    border-radius: 50%;

    background: #dcfce7;

    color: var(--success);

    font-size: 30px;
    font-weight: 900;
}


.result-card h2 {
    margin-bottom: 8px;

    font-size: 34px;
}


/* =========================================================
   35. RESULT STATS
   ========================================================= */

.result-stats {
    display: grid;

    grid-template-columns: 1fr 1fr;

    gap: 10px;

    margin: 25px 0;
}


.result-stats > div {
    padding: 15px;

    border: 1px solid var(--border);

    border-radius: 13px;
}


.result-stats span {
    display: block;

    color: var(--muted);

    font-size: 12px;
}


.result-stats strong {
    display: block;

    margin-top: 5px;

    font-size: 23px;
}


/* =========================================================
   36. RESULT WORDS
   ========================================================= */

.result-words {
    display: flex;

    flex-wrap: wrap;

    justify-content: center;

    gap: 7px;
}


.result-word {
    padding: 7px 10px;

    border-radius: 8px;

    background: #f1f5f9;

    font-size: 12px;
    font-weight: 750;
}


/* =========================================================
   37. RESULT ACTIONS
   ========================================================= */

.result-actions {
    display: grid;

    grid-template-columns: 1fr 1fr;

    gap: 10px;

    margin-top: 25px;
}


.result-actions .primary-btn,
.result-actions .secondary-btn {
    margin-top: 0;
}


/* =========================================================
   38. TABLET
   ========================================================= */

@media (max-width: 850px) {

    .preview-layout,
    .game-layout {
        grid-template-columns: 1fr;
    }

    .word-list {
        max-height: 280px;
    }
}


/* =========================================================
   39. MOBILE
   ========================================================= */

@media (max-width: 620px) {

    .app {
        width: calc(100% - 20px);

        padding-top: 17px;
    }


    .topbar,
    .game-header {
        align-items: flex-start;

        flex-direction: column;
    }


    .topbar .ghost-btn {
        width: 100%;
    }


    .setup-card,
    .word-card,
    .result-card {
        padding: 20px;
    }


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


    .header-actions {
        width: 100%;
    }


    .header-actions button {
        flex: 1;
    }


    .stats {
        width: 100%;
    }


    .stat {
        flex: 1;
    }


    .board {
        gap: 2px;
    }


    .cell {
        border-radius: 4px;
    }


    .result-actions {
        grid-template-columns: 1fr;
    }
}
