/* ═══════════════════════════════════════════════════════════════════════════
   Визуальные подтесты WISC — Стили v2
   ═══════════════════════════════════════════════════════════════════════════ */

.vs-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}
.vs-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}
.vs-instr {
    background: var(--info-bg);
    color: var(--info);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    margin-bottom: 16px;
    line-height: 1.5;
}
.vs-trial-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.vs-trial-nav button:disabled { opacity: 0.4; cursor: default; }
.vs-score-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    flex-wrap: wrap;
}

/* ── Score buttons ────────────────────────────────────────────────────── */
.vs-score-btn {
    padding: 7px 18px;
    border-radius: 6px;
    border: 2px solid var(--border);
    background: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-size: 0.9rem;
}
.vs-score-btn:hover { border-color: var(--primary); background: var(--info-bg); }
.vs-score-btn.selected { border-color: var(--primary); background: var(--primary); color: #fff; }
.vs-s2 { border-color: #22c55e40; }
.vs-s2.selected { background: #22c55e; border-color: #22c55e; color: #fff; }
.vs-s1 { border-color: #eab30840; }
.vs-s1.selected { background: #eab308; border-color: #eab308; color: #fff; }
.vs-s0 { border-color: #ef444440; }
.vs-s0.selected { background: #ef4444; border-color: #ef4444; color: #fff; }

/* ═══════════════════════════════════════════════════════════════════════════
   БЛОК-ДИЗАЙН (КУБИКИ КОСА) v2
   ═══════════════════════════════════════════════════════════════════════════ */

.bd-workspace {
    display: flex;
    gap: 28px;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

/* Reference pattern */
.bd-ref-panel { text-align: center; }
.bd-ref-title { font-weight: 600; margin-bottom: 8px; font-size: 0.9rem; color: var(--text-secondary); }
.bd-ref-grid {
    display: inline-grid;
    gap: 3px;
    padding: 10px;
    background: #f1f5f9;
    border-radius: 8px;
    border: 2px solid var(--border);
}
.bd-ref-cell {
    width: 42px; height: 42px; border-radius: 5px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem;
    box-shadow: 1px 2px 4px rgba(0,0,0,0.12);
}
.bd-c-R { background: linear-gradient(135deg, #f87171, #dc2626); color: #fff; }
.bd-c-W { background: linear-gradient(135deg, #fff, #e2e8f0); color: #374151; border: 1.5px solid #cbd5e1; }
.bd-c-B { background: linear-gradient(135deg, #60a5fa, #2563eb); color: #fff; }
.bd-c-Y { background: linear-gradient(135deg, #fde047, #eab308); color: #78350f; }

/* Working grid */
.bd-grid-panel { display: flex; align-items: center; }
.bd-grid {
    display: inline-grid;
    gap: 4px;
    padding: 12px;
    background: #f8fafc;
    border: 2px dashed var(--border);
    border-radius: 10px;
    position: relative;
}
.bd-cell {
    width: 74px; height: 74px;
    border: 2.5px dashed #cbd5e1;
    border-radius: 8px;
    background: rgba(255,255,255,0.7);
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s ease;
    position: relative;
}
.bd-cell.snap-hl {
    border-color: #6366f1 !important;
    border-style: solid !important;
    background: rgba(99, 102, 241, 0.1) !important;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2), inset 0 0 20px rgba(99, 102, 241, 0.06) !important;
    transform: scale(1.04);
}
.bd-cell[data-occ="1"] {
    border-color: transparent;
    background: transparent;
    box-shadow: none;
}
.bd-cell.bd-cell-correct {
    background: rgba(34, 197, 94, 0.08);
    box-shadow: inset 0 0 0 2px rgba(34, 197, 94, 0.4);
}
.bd-cell.bd-cell-wrong {
    background: rgba(239, 68, 68, 0.06);
    box-shadow: inset 0 0 0 2px rgba(239, 68, 68, 0.3);
}

/* ── 3D Cube ──────────────────────────────────────────────────────────── */
.bd-cube {
    width: 68px; height: 68px;
    cursor: grab;
    user-select: none;
    touch-action: none;
    position: relative;
    z-index: 5;
    perspective: 200px;
}
.bd-cube:active { cursor: grabbing; }

.bd-cube-3d {
    width: 100%; height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transform: rotateX(-20deg) rotateY(25deg);
    transition: transform 0.2s ease;
}
.bd-cube:hover .bd-cube-3d {
    transform: rotateX(-25deg) rotateY(30deg) translateZ(3px);
}

/* Cube faces */
.bd-face {
    position: absolute;
    border-radius: 4px;
    backface-visibility: hidden;
}

/* Top face — the color face */
.bd-face-top {
    width: 100%; height: 100%;
    top: 0; left: 0;
    transform: rotateX(90deg) translateZ(34px);
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
}

/* Left face — darker shade */
.bd-face-left {
    width: 100%; height: 34px;
    bottom: 0; left: 0;
    transform-origin: bottom left;
    transform: rotateX(-90deg);
    border-radius: 0 0 4px 4px;
}

/* Right face — lighter shade */
.bd-face-right {
    width: 34px; height: 100%;
    top: 0; right: 0;
    transform-origin: top right;
    transform: rotateY(90deg);
    border-radius: 0 4px 4px 0;
}

/* Color variants for top face */
.bd-cf-R { background: linear-gradient(135deg, #f87171 30%, #dc2626 100%); }
.bd-cf-W { background: linear-gradient(135deg, #ffffff 30%, #e2e8f0 100%); border: 1px solid #d1d5db; }
.bd-cf-B { background: linear-gradient(135deg, #60a5fa 30%, #2563eb 100%); }
.bd-cf-Y { background: linear-gradient(135deg, #fde047 30%, #eab308 100%); }

/* Left face colors (darker) */
.bd-cfl-R { background: linear-gradient(to bottom, #b91c1c, #991b1b); }
.bd-cfl-W { background: linear-gradient(to bottom, #cbd5e1, #94a3b8); }
.bd-cfl-B { background: linear-gradient(to bottom, #1d4ed8, #1e40af); }
.bd-cfl-Y { background: linear-gradient(to bottom, #ca8a04, #a16207); }

/* Right face colors (lighter) */
.bd-cfr-R { background: linear-gradient(to right, #fca5a5, #f87171); }
.bd-cfr-W { background: linear-gradient(to right, #f1f5f9, #e2e8f0); }
.bd-cfr-B { background: linear-gradient(to right, #93c5fd, #60a5fa); }
.bd-cfr-Y { background: linear-gradient(to right, #fef08a, #fde047); }

/* Rotation animation */
.bd-cube.rotating .bd-cube-3d {
    animation: cubeRotate3D 0.42s ease-in-out;
}
@keyframes cubeRotate3D {
    0%   { transform: rotateX(-20deg) rotateY(25deg) scale(1); }
    45%  { transform: rotateX(-20deg) rotateY(115deg) scale(0.92); }
    55%  { transform: rotateX(-20deg) rotateY(115deg) scale(0.92); }
    100% { transform: rotateX(-20deg) rotateY(25deg) scale(1); }
}

/* ── Palette with fixed slots ─────────────────────────────────────────── */
.bd-palette-wrap { text-align: center; margin-top: 4px; }
.bd-palette-title { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 8px; }
.bd-palette {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    padding: 14px;
    background: #f1f5f9;
    border-radius: 10px;
    min-height: 90px;
    border: 2px solid var(--border);
}
.bd-palette-slot {
    width: 72px; height: 72px;
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    transition: border-color 0.2s;
    background: rgba(255,255,255,0.5);
}
.bd-palette-slot:hover {
    border-color: #9ca3af;
}

/* ── Match indicator bar ─────────────────────────────────────────────── */
.bd-match-bar {
    text-align: center;
    padding: 8px 14px;
    margin-bottom: 12px;
    font-size: 0.88rem;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.3s;
    min-height: 20px;
}
.bd-match-bar.bd-match-partial {
    background: #f0f9ff;
    color: #0369a1;
    border: 1px solid #bae6fd;
}
.bd-match-bar.bd-match-perfect {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
    font-weight: 700;
}
.bd-match-icon {
    font-size: 1.1rem;
    margin-right: 4px;
}

/* Timer */
.bd-timer-bar {
    display: flex; gap: 16px; justify-content: center; flex-wrap: wrap;
    padding: 10px; margin-top: 12px;
    background: #f1f5f9; border-radius: 8px;
    font-size: 0.85rem; color: var(--text-secondary);
    transition: background 0.3s;
}
.bd-timer-bar.partial { background: #fef3c7; color: #92400e; }
.bd-timer-bar.time-up { background: #fee2e2; color: #991b1b; animation: timerPulse 1s ease infinite; }
@keyframes timerPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }
.bd-timer-bar strong { font-size: 1rem; }

/* ═══════════════════════════════════════════════════════════════════════════
   ШИФРОВКА
   ═══════════════════════════════════════════════════════════════════════════ */

.cd-key { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding: 12px; background: #f1f5f9; border-radius: 8px; margin-bottom: 14px; }
.cd-key-item { display: flex; align-items: center; gap: 6px; background: #fff; padding: 6px 12px; border-radius: 6px; border: 1px solid var(--border); }
.cd-digit { font-weight: 700; font-size: 1.1rem; color: var(--primary); }
.cd-arrow { color: var(--text-secondary); font-size: 0.9rem; }
.cd-symbol { font-size: 1.3rem; }

.cd-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; max-width: 520px; margin: 0 auto 14px; }
.cd-cell { text-align: center; padding: 4px 2px; border: 1px solid var(--border); border-radius: 4px; cursor: pointer; transition: all 0.15s; min-height: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.cd-cell:hover { border-color: var(--primary); background: var(--info-bg); }
.cd-cell.cd-active { border-color: var(--primary); background: var(--info-bg); box-shadow: 0 0 0 2px var(--primary-light); }
.cd-cell-digit { font-size: 0.75rem; color: var(--text-secondary); }
.cd-cell-answer { font-size: 1.2rem; min-height: 1.2em; }
.cd-cell.cd-correct { background: #d1fae5; border-color: #22c55e; }
.cd-cell.cd-wrong { background: #fee2e2; border-color: #ef4444; }

.cd-palette { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 14px; }
.cd-sym-btn { font-size: 1.5rem; padding: 8px 16px; border: 2px solid var(--border); border-radius: 8px; background: #fff; cursor: pointer; transition: all 0.15s; min-width: 52px; }
.cd-sym-btn:hover { border-color: var(--primary); background: var(--info-bg); transform: scale(1.05); }
.cd-status { display: flex; justify-content: space-between; padding: 10px; background: #f1f5f9; border-radius: 8px; font-size: 0.9rem; font-weight: 600; }

/* ═══════════════════════════════════════════════════════════════════════════
   ПОИСК СИМВОЛОВ
   ═══════════════════════════════════════════════════════════════════════════ */

.ss-play-area { text-align: center; padding: 30px; background: #f8fafc; border-radius: 12px; border: 2px solid var(--border); margin-bottom: 14px; min-height: 180px; }
.ss-target { margin-bottom: 20px; }
.ss-label { font-size: 0.85rem; color: var(--text-secondary); display: block; margin-bottom: 6px; }
.ss-sym-lg { display: inline-block; font-size: 2rem; margin: 0 6px; padding: 8px 14px; background: #fff; border: 2px solid var(--border); border-radius: 8px; min-width: 44px; text-align: center; }
.ss-search-group { margin-bottom: 20px; }
.ss-search-sym { margin: 0 4px; padding: 10px 16px; background: #fff; border: 2px solid #e2e8f0; border-radius: 8px; font-size: 2rem; }
.ss-btns { display: flex; gap: 12px; justify-content: center; }
.ss-status { display: flex; justify-content: space-between; padding: 10px 14px; background: #f1f5f9; border-radius: 8px; font-size: 0.85rem; font-weight: 500; margin-bottom: 12px; }
.ss-done { font-size: 1.2rem; font-weight: 600; color: var(--primary); padding: 20px; }

/* ═══════════════════════════════════════════════════════════════════════════
   ЛАБИРИНТЫ
   ═══════════════════════════════════════════════════════════════════════════ */

.mz-canvas-wrap { display: flex; justify-content: center; margin-bottom: 10px; }
.mz-canvas-wrap canvas { border: 2px solid var(--border); border-radius: 8px; cursor: crosshair; max-width: 100%; touch-action: none; }
.mz-status { text-align: center; font-weight: 600; font-size: 0.9rem; margin-bottom: 10px; }

/* ═══════════════════════════════════════════════════════════════════════════
   МАТРИЦЫ
   ═══════════════════════════════════════════════════════════════════════════ */

.mx-area { display: flex; justify-content: center; margin-bottom: 16px; }
.mx-grid { display: inline-grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 10px; background: #f1f5f9; border-radius: 10px; border: 2px solid var(--border); }
.mx-cell { width: 80px; height: 80px; display: flex; align-items: center; justify-content: center; background: #fff; border-radius: 6px; border: 1px solid #e2e8f0; }
.mx-empty { border: 2px dashed var(--primary); background: var(--info-bg); font-size: 1.5rem; font-weight: 700; color: var(--primary); }
.mx-choices { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.mx-choice-btn { width: 80px; height: 80px; display: flex; align-items: center; justify-content: center; background: #fff; border: 2px solid var(--border); border-radius: 8px; cursor: pointer; transition: all 0.2s; }
.mx-choice-btn:hover { border-color: var(--primary); transform: scale(1.05); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.mx-choice-selected { border-color: #22c55e !important; background: #d1fae5 !important; box-shadow: 0 0 0 3px rgba(34,197,94,0.2) !important; }
.mx-choice-wrong { border-color: #ef4444 !important; background: #fee2e2 !important; }

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
    .bd-cell { width: 56px; height: 56px; }
    .bd-cube { width: 52px; height: 52px; }
    .bd-palette-slot { width: 56px; height: 56px; }
    .bd-ref-cell { width: 32px; height: 32px; font-size: 0.7rem; }
    .mx-cell { width: 64px; height: 64px; }
    .mx-choice-btn { width: 64px; height: 64px; }
    .cd-grid { grid-template-columns: repeat(7, 1fr); }
}