.solve-page {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem 2rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 1.5rem;
    align-items: flex-start;
}

/* Grid items must not overflow their column */
.solve-page > * { min-width: 0; }

/* ── STATS BAR ── */
.stats-bar {
    display: flex;
    gap: 1.5rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    align-items: center;
    box-shadow: var(--shadow);
}
.stat-item { display: flex; align-items: center; gap: .4rem; font-size: .875rem; color: var(--muted); }
.stat-item strong { color: var(--text); font-weight: 700; }

.wishlist-btn {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: .4rem;
    background: transparent;
    border: 1.5px solid var(--border);
    border-radius: 50px;
    padding: .4rem 1rem;
    color: var(--muted);
    font-size: .875rem;
    cursor: pointer;
    transition: all .2s;
    font-weight: 500;
}
.wishlist-btn:hover,
.wishlist-btn.active { border-color: #ef4444; color: #ef4444; background: #fef2f2; }
.wishlist-btn .heart { font-size: 1rem; }

/* ── ZOOM CONTROLS ── */
.cw-zoom-bar {
    display: flex;
    align-items: center;
    gap: .35rem;
    margin-bottom: .5rem;
    justify-content: flex-end;
}
.cw-zoom-btn {
    width: 30px; height: 30px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    color: var(--text);
    font-size: 1.05rem;
    line-height: 1;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s, border-color .15s;
    flex-shrink: 0;
}
.cw-zoom-btn:hover,
.cw-zoom-btn:active { background: var(--surface); border-color: var(--primary); color: var(--primary); }
.cw-zoom-label {
    font-size: .72rem;
    color: var(--muted);
    min-width: 34px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* ── CROSSWORD GRID ── */
.cw-table-wrap {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 100%;
    box-shadow: var(--shadow);
    overflow: hidden;
    touch-action: pan-y; /* default: allow vertical scroll */
}
.cw-table-wrap.cw-zoomed {
    cursor: grab;
    touch-action: none; /* we handle all touch when zoomed */
}
.cw-table-wrap.cw-zoomed:active { cursor: grabbing; }

.cw-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    transform-origin: 0 0;
    will-change: transform;
    background: #cccccc; /* sub-pixel bo'shliqlarni yashiradi */
}
.cw-table td {
    padding: 0;
    border: none;
    vertical-align: top;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    position: relative;
}
/* padding-bottom: 100% trick — td ni barcha brauzerlarda to'g'ri kvadrat qiladi */
.cw-table td::before {
    content: '';
    display: block;
    padding-bottom: 100%;
}

/* ── MOBILE CLUE TOAST ── */
.mobile-clue-toast {
    display: none;
    position: fixed;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, .93);
    color: #fff;
    padding: .55rem 1.1rem;
    border-radius: 50px;
    font-size: .8rem;
    font-weight: 600;
    z-index: 3000;
    max-width: 88vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 4px 20px rgba(0,0,0,.3);
    pointer-events: none;
}
.mobile-clue-toast.visible {
    display: block;
    animation: toastSlideIn .22s ease;
}
@keyframes toastSlideIn {
    from { opacity: 0; top: 4px; }
    to   { opacity: 1; top: 14px; }
}
.cw-cell {
    position: absolute;
    inset: 0; /* td ni to'liq to'ldiradi, height: 100% ga bog'liq emas */
    overflow: hidden;
    background: #fff;
    border: 1.5px solid #e5e7eb;
    cursor: pointer;
    transition: background .15s;
}
.cw-cell:focus-within { border-color: var(--primary); z-index: 5; }
.cw-cell.black { background: #1c1b1b; border-color: #cccccc; cursor: default; }
.cw-table-wrap.cw-zoomed .cw-cell.black { cursor: grab; }
.cw-table-wrap.cw-zoomed .cw-cell.black:active { cursor: grabbing; }
.cw-table-wrap.cw-zoomed .cell-input { cursor: grab; }
.cw-table-wrap.cw-zoomed:active .cell-input { cursor: grabbing; }
.cw-cell.correct { background: rgba(16,185,129,.1); border-color: var(--green); }
.cw-cell.wrong   { background: rgba(239,68,68,.1);  border-color: var(--red); }
.cw-cell.active  { border-color: var(--primary) !important; box-shadow: 0 0 0 2px rgba(249,115,22,.2); }
.cw-cell.word-hl { background: var(--primary-l); }

.cell-number {
    position: absolute;
    top: 2px; left: 3px;
    font-size: 10px; /* doimiy 10px — brauzer inflatsiya qilmaydi; vizual o'lcham JS scale bilan */
    font-weight: 700;
    color: var(--muted);
    line-height: 1;
    pointer-events: none;
    z-index: 2;
    transform: scale(var(--cw-num-scale, 0.6));
    transform-origin: top left;
}
.cell-input {
    position: absolute;
    inset: 0;
    width: 100%; height: 100%;
    background: transparent;
    border: none; outline: none;
    text-align: center;
    font-size: var(--cw-cell-font, 9px);
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    cursor: pointer;
    padding: 0;
    padding-top: var(--cw-cell-pt, 35%);
    line-height: 1;
    caret-color: transparent;
}
.cell-input.digraph { font-size: var(--cw-cell-font-dg, 7px); }

/* ── CLUES PANEL ── */
.clues-panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    position: sticky;
    top: 84px;
    box-shadow: var(--shadow);
}
.clues-tabs { display: grid; grid-template-columns: 1fr 1fr; }
.clue-tab {
    padding: .85rem;
    text-align: center;
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid var(--border);
    color: var(--muted);
    transition: all .2s;
    background: none;
    border-left: none; border-right: none; border-top: none;
}
.clue-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.clues-body { padding: .75rem; max-height: 500px; overflow-y: auto; }
.clue-item {
    display: flex;
    gap: .6rem;
    padding: .5rem .6rem;
    border-radius: 8px;
    font-size: .82rem;
    cursor: pointer;
    transition: background .15s;
    align-items: flex-start;
    border-left: 3px solid transparent;
}
.clue-item:hover { background: var(--surface); }
.clue-item.active { background: var(--primary-l); border-left-color: var(--primary); }
.clue-item.solved { opacity: .45; text-decoration: line-through; }
.clue-num { font-weight: 700; color: var(--primary); min-width: 22px; flex-shrink: 0; }
.clue-text { color: var(--text2); line-height: 1.4; }

/* ── ACTIVE CLUE BAR ── */
.active-clue-bar {
    background: var(--primary-l);
    border: 1.5px solid rgba(249,115,22,.2);
    border-radius: var(--radius);
    padding: .75rem 1rem;
    margin-bottom: 1rem;
    font-size: .875rem;
    min-height: 48px;
    display: flex;
    align-items: center;
    gap: .6rem;
}
.active-clue-bar .num { font-weight: 700; color: var(--primary); }
.active-clue-bar .dir {
    font-size: .72rem;
    background: var(--primary);
    color: #fff;
    padding: .1rem .5rem;
    border-radius: 50px;
}
.active-clue-bar .text { color: var(--text); }

/* ── ACTIONS ── */
.solve-actions {
    display: flex;
    gap: .75rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

/* ── SUCCESS OVERLAY ── */
.success-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.55); z-index: 9000;
    align-items: center; justify-content: center;
}
.success-overlay.show { display: flex; }
.success-box {
    background: var(--card);
    border: 2px solid var(--green);
    border-radius: 20px;
    padding: 3rem;
    text-align: center;
    max-width: 420px;
    animation: popIn .4s cubic-bezier(.34,1.56,.64,1);
    box-shadow: 0 20px 60px rgba(0,0,0,.18);
}
@keyframes popIn { from { opacity:0; transform:scale(.7); } to { opacity:1; transform:scale(1); } }
.success-icon { font-size: 4rem; margin-bottom: 1rem; }
.success-title { font-family:'Orbitron',sans-serif; font-size:1.6rem; font-weight:900; color:var(--green); margin-bottom:.75rem; }
.success-desc  { color: var(--muted); margin-bottom: 2rem; line-height: 1.6; }
.success-time  { font-size:1.2rem; font-weight:700; color:var(--primary); margin-bottom:.5rem; }

/* ── TIMER ── */
.timer { font-family:'Orbitron',sans-serif; font-size:.95rem; color:var(--primary); font-weight:700; }

@media (max-width: 1140px) {
    .solve-page {
        grid-template-columns: 1fr;
        padding: 1.5rem;
    }
    .clues-panel { position: static; }
}
@media (max-width: 600px) {
    .solve-page { padding: .75rem; }
    .cw-table-wrap { padding: .75rem; }
    .stats-bar { gap: .75rem; padding: .75rem 1rem; }
    .solve-actions { gap: .5rem; }
    .solve-actions .btn { font-size: .78rem; padding: .45rem .75rem; }
}

/* ── FULLSCREEN ── */
.cw-table-wrap:fullscreen,
.cw-table-wrap:-webkit-full-screen {
    aspect-ratio: auto !important;
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0 !important;
    padding: 56px 1rem 1rem !important;
    background: #0f172a !important;
}

/* ── FULLSCREEN CLUE OVERLAY ── */
.cw-fullscreen-clue {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    right: 10px;
    background: rgba(15, 23, 42, .94);
    border: 1.5px solid rgba(249, 115, 22, .45);
    border-radius: 8px;
    padding: .45rem .85rem;
    font-size: .82rem;
    font-weight: 500;
    color: #f1f5f9;
    align-items: center;
    gap: .5rem;
    z-index: 99999;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    line-height: 1.4;
}
.cw-fullscreen-clue.fs-visible { display: flex; }
.cw-fullscreen-clue .fs-clue-text { flex: 1; }
.cw-fs-exit {
    background: none;
    border: none;
    color: rgba(255,255,255,.6);
    cursor: pointer;
    font-size: .9rem;
    padding: 0;
    flex-shrink: 0;
    line-height: 1;
    transition: color .15s;
}
.cw-fs-exit:hover { color: #fff; }

/* ── FULLSCREEN BUTTON ── */
.cw-fs-btn {
    width: 30px; height: 30px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    color: var(--text);
    font-size: .85rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s, border-color .15s;
    flex-shrink: 0;
}
.cw-fs-btn:hover { background: var(--surface); border-color: var(--primary); color: var(--primary); }
