* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #0f1419;
    min-height: 100vh;
    padding: 20px;
    position: relative;
    overflow-x: hidden;
}

/* Фон «мозг / интеллект»: нейронная сеть, глубина мысли, знание */
.catalog-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
}

/* Базовый градиент — глубина, фокус */
.catalog-background::before {
    content: '';
    position: absolute;
    inset: 0;
    background: 
        radial-gradient(ellipse 120% 80% at 50% 0%, rgba(30, 58, 138, 0.5) 0%, transparent 50%),
        radial-gradient(ellipse 100% 100% at 20% 100%, rgba(88, 28, 135, 0.35) 0%, transparent 45%),
        radial-gradient(ellipse 80% 60% at 85% 20%, rgba(37, 99, 235, 0.3) 0%, transparent 40%),
        linear-gradient(180deg, #0f172a 0%, #1e1b4b 40%, #0f1419 100%);
    animation: backgroundPulse 12s ease-in-out infinite;
}

/* «Нейроны» — мягкие светящиеся узлы */
.catalog-background::after {
    content: '';
    position: absolute;
    inset: 0;
    background: 
        radial-gradient(circle 8vmin at 15% 25%, rgba(96, 165, 250, 0.25) 0%, transparent 50%),
        radial-gradient(circle 6vmin at 75% 15%, rgba(167, 139, 250, 0.2) 0%, transparent 50%),
        radial-gradient(circle 10vmin at 50% 70%, rgba(59, 130, 246, 0.2) 0%, transparent 50%),
        radial-gradient(circle 5vmin at 88% 55%, rgba(129, 140, 248, 0.22) 0%, transparent 50%),
        radial-gradient(circle 7vmin at 25% 85%, rgba(139, 92, 246, 0.18) 0%, transparent 50%);
    opacity: 0.9;
    animation: neuralGlow 8s ease-in-out infinite;
}

/* Сетка знаний — лёгкий узор */
.catalog-background {
    background-image: 
        linear-gradient(rgba(96, 165, 250, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(96, 165, 250, 0.03) 1px, transparent 1px);
    background-size: 32px 32px;
    background-position: 0 0, 0 0;
}

@keyframes backgroundPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.92; }
}

@keyframes neuralGlow {
    0%, 100% { opacity: 0.9; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.02); }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.catalog-header {
    text-align: center;
    margin-bottom: 40px;
    padding: 20px;
    animation: fadeInDown 0.6s ease-out;
}

.main-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 10px;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.3);
}

.subtitle {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 300;
}

.ads-controls {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}


.ads-reward-btn {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: #ffffff;
    border: none;
    padding: 12px 18px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(34, 197, 94, 0.35);
}

.our-apps-btn {
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    box-shadow: 0 10px 24px rgba(99, 102, 241, 0.35);
}

.our-apps-modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(10px);
}

.our-apps-modal.hidden {
    display: none;
}

.our-apps-card {
    width: 100%;
    max-width: 520px;
    border-radius: 18px;
    padding: 16px 16px 14px;
    background: rgba(15, 23, 42, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}

.our-apps-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.95);
    text-align: center;
    margin-bottom: 12px;
}

.our-apps-list {
    display: grid;
    gap: 10px;
    margin-bottom: 14px;
}

.our-apps-item {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 12px;
    border-radius: 14px;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.92);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.10);
}

.our-apps-item:hover {
    background: rgba(255, 255, 255, 0.12);
}

.our-apps-item-name {
    font-weight: 700;
}

.our-apps-item-link {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.75);
}

.our-apps-close {
    width: 100%;
}

.ads-timer {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.85);
}

.ads-timer.hidden {
    display: none;
}


.tests-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    padding: 20px 0;
}

.test-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    animation: fadeInUp 0.6s ease-out;
    animation-fill-mode: both;
}

.test-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: linear-gradient(90deg, #3b82f6, #6366f1, #8b5cf6);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

.test-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
}

.test-card:hover::before {
    transform: scaleX(1);
}

.test-card:nth-child(1) { animation-delay: 0.1s; }
.test-card:nth-child(2) { animation-delay: 0.2s; }
.test-card:nth-child(3) { animation-delay: 0.3s; }
.test-card:nth-child(4) { animation-delay: 0.4s; }
.test-card:nth-child(5) { animation-delay: 0.5s; }
.test-card:nth-child(6) { animation-delay: 0.6s; }
.test-card:nth-child(7) { animation-delay: 0.7s; }
.test-card:nth-child(8) { animation-delay: 0.8s; }
.test-card:nth-child(9) { animation-delay: 0.9s; }
.test-card:nth-child(10) { animation-delay: 1.0s; }
.test-card:nth-child(11) { animation-delay: 1.1s; }
.test-card:nth-child(12) { animation-delay: 1.2s; }
.test-card:nth-child(13) { animation-delay: 1.3s; }
.test-card:nth-child(14) { animation-delay: 1.4s; }
.test-card:nth-child(15) { animation-delay: 1.5s; }
.test-card:nth-child(16) { animation-delay: 1.6s; }
.test-card:nth-child(17) { animation-delay: 1.7s; }

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.test-icon {
    font-size: 4rem;
    text-align: center;
    margin-bottom: 20px;
    animation: iconFloat 3s ease-in-out infinite;
}

.test-card:nth-child(1) .test-icon { animation-delay: 0s; }
.test-card:nth-child(2) .test-icon { animation-delay: 0.5s; }
.test-card:nth-child(3) .test-icon { animation-delay: 1s; }
.test-card:nth-child(4) .test-icon { animation-delay: 1.5s; }
.test-card:nth-child(5) .test-icon { animation-delay: 2s; }
.test-card:nth-child(6) .test-icon { animation-delay: 2.5s; }
.test-card:nth-child(7) .test-icon { animation-delay: 3s; }
.test-card:nth-child(8) .test-icon { animation-delay: 3.5s; }
.test-card:nth-child(9) .test-icon { animation-delay: 4s; }
.test-card:nth-child(10) .test-icon { animation-delay: 4.5s; }
.test-card:nth-child(11) .test-icon { animation-delay: 5s; }
.test-card:nth-child(12) .test-icon { animation-delay: 5.5s; }
.test-card:nth-child(13) .test-icon { animation-delay: 6s; }
.test-card:nth-child(14) .test-icon { animation-delay: 6.5s; }
.test-card:nth-child(15) .test-icon { animation-delay: 7s; }
.test-card:nth-child(16) .test-icon { animation-delay: 7.5s; }
.test-card:nth-child(17) .test-icon { animation-delay: 8s; }

@keyframes iconFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.test-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 15px;
    text-align: center;
}

.test-description {
    font-size: 1rem;
    color: #4a5568;
    line-height: 1.6;
    margin-bottom: 20px;
    text-align: center;
}

.test-link {
    display: block;
    width: 100%;
    padding: 15px 30px;
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 50%, #8b5cf6 100%);
    color: white;
    text-align: center;
    text-decoration: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.test-link::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.test-link:hover::before {
    width: 300px;
    height: 300px;
}

.test-link:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(59, 130, 246, 0.45);
}

.test-link:active {
    transform: scale(0.98);
}

.test-link-text {
    position: relative;
    z-index: 1;
}

@media (max-width: 768px) {
    .main-title { font-size: 2rem; }
    .subtitle { font-size: 1rem; }
    .tests-grid { grid-template-columns: 1fr; gap: 20px; }
    .test-card { padding: 25px; }
    .test-icon { font-size: 3rem; }
    .test-title { font-size: 1.3rem; }
}

@media (max-width: 480px) {
    body { padding: 10px; }
    .catalog-header { margin-bottom: 30px; padding: 15px; }
    .main-title { font-size: 1.8rem; }
    .test-card { padding: 20px; }
}


.hidden { display: none !important; }

/* Кнопки «Начать тест» в тестах: убираем задержку тапа на мобильных */
.test-root #start-btn,
.test-root #startTestBtn,
.test-root .start-btn,
.test-root .btn-primary {
  touch-action: manipulation;
  cursor: pointer;
}

.test-root {
    display: none;
    min-height: 100vh;
}

.test-root.active {
    display: block;
}

.back-button {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 20;
    background: rgba(31, 42, 68, 0.95);
    color: #ffffff;
    border: none;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.95rem;
    cursor: pointer;
    display: none;
}

.back-button.active {
    display: block;
}

.app-subtitle {
    order: 2;
    flex: 1;
    text-align: center;
    margin: 0;
    min-width: 0;
}

.btn-1 { 
    order: 1;
    flex-shrink: 0;
}
.btn-2 { 
    order: 3;
    flex-shrink: 0;
}
.actions {
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    width: 100%;
    max-width: 900px;
    margin: 12px auto 0;
}

.neutral-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 16px;
    border-radius: 12px;
    border: 2px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all .3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    min-width: 44px;
    min-height: 44px;
}

.neutral-btn:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.3);
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.neutral-btn:active {
    transform: translateY(0);
}

.neutral-btn svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

@media (max-width: 768px) {
    .actions {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }
    .btn-1 { order: 1; }
    .btn-2 { order: 2; }
    .app-subtitle {
        order: 3;
        width: 100%;
        margin-top: 8px;
        flex: none;
    }
    .neutral-btn {
        padding: 10px 14px;
        min-width: 40px;
        min-height: 40px;
    }
    .neutral-btn svg {
        width: 18px;
        height: 18px;
    }
}
